40 releases (15 breaking)

0.17.0 Jun 4, 2025
0.14.0 Feb 7, 2025
0.13.0 Nov 22, 2024
0.11.0 Dec 20, 2023
0.1.0 Mar 23, 2020

#162 in Command-line interface

Download history 250732/week @ 2025-09-29 260083/week @ 2025-10-06 251992/week @ 2025-10-13 236173/week @ 2025-10-20 260951/week @ 2025-10-27 282424/week @ 2025-11-03 234556/week @ 2025-11-10 331855/week @ 2025-11-17 225829/week @ 2025-11-24 289362/week @ 2025-12-01 287333/week @ 2025-12-08 271898/week @ 2025-12-15 135411/week @ 2025-12-22 140336/week @ 2025-12-29 287269/week @ 2026-01-05 324697/week @ 2026-01-12

904,219 downloads per month
Used in 766 crates (2 directly)

MIT license

345KB
9K SLoC

papergrid

This is library for pretty tables.

It has relatively low level API. If you're interested in a more friendly one take a look at tabled.

Usage

use papergrid::{
    colors::NoColors,
    config::{
        spanned::SpannedConfig, AlignmentHorizontal, AlignmentVertical, Borders, Entity, Indent,
        Sides,
    },
    dimension::{spanned::SpannedGridDimension, Estimate},
    grid::peekable::PeekableGrid,
    records::vec_records::{CellInfo, VecRecords},
};

fn main() {
    let mut cfg = SpannedConfig::default();
    cfg.set_borders(Borders {
        top: Some('-'),
        top_left: Some('+'),
        top_right: Some('+'),
        top_intersection: Some('+'),
        bottom: Some('-'),
        bottom_left: Some('+'),
        bottom_right: Some('+'),
        bottom_intersection: Some('+'),
        horizontal: Some('-'),
        left_intersection: Some('+'),
        right_intersection: Some('+'),
        vertical: Some('|'),
        left: Some('|'),
        right: Some('|'),
        intersection: Some('+'),
    });
    cfg.set_column_span((1, 1), 3);
    cfg.set_row_span((0, 0), 2);
    cfg.set_alignment_horizontal((1, 0).into(), AlignmentHorizontal::Center);
    cfg.set_alignment_vertical(Entity::Global, AlignmentVertical::Center);
    cfg.set_padding(
        (0, 0).into(),
        Sides::new(
            Indent::spaced(4),
            Indent::spaced(4),
            Indent::spaced(1),
            Indent::spaced(1),
        ),
    );

    let data = [
        ["Papergrid", "is a library", "for print tables", "!"],
        ["", "Just like this", "", ""],
    ];

    let data = data
        .iter()
        .map(|row| row.iter().map(CellInfo::new).collect())
        .collect();

    let records = VecRecords::new(data);

    let mut dims = SpannedGridDimension::default();
    dims.estimate(&records, &cfg);

    let grid = PeekableGrid::new(&records, &cfg, &dims, NoColors).to_string();

    println!("{grid}");
}

Running the example you must see.

+-----------------+------------+----------------+-+
|                 |is a library|for print tables|!|
+    Papergrid    +------------+----------------+-+
|                 |Just like this                 |
+-----------------+------------+----------------+-+

Dependencies

~2MB
~27K SLoC