Pretty Print

A Gleam library for formatting documents like source code.

See the documentation for many examples:

Available in hex:

Render documents to String using the least number of lines possible while trying to stay under a certain number of columns.

Works well for constraining source code to a particular width.


// The same Document may pretty print as
[ 1, 2, 3, 4 ]

// or
[ 1
, 2
, 3
, 4
// depending on the desired maximum columns.

// Similarly

// may break to

The core concepts here are:

This is essentially some convenience wrappers around this algorithm:


This package can be installed by adding pretty_print to your rebar.config dependencies:

{deps, [