Programming language: Rust
License: The Unlicense
Tags: Elastic     Tabs     Aligned     Whitespace     Table    
Latest version: v1.2.1

tabwriter alternatives and similar packages

Based on the "Text processing" category.
Alternatively, view tabwriter alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of tabwriter or a related project?

Add another 'Text processing' Package


tabwriter is a crate that implements elastic tabstops. It provides both a library for wrapping Rust Writers and a small program that exposes the same functionality at the command line.

Build status

Dual-licensed under MIT or the UNLICENSE.

Simple example of library

use std::io::Write;

use tabwriter::TabWriter;

let mut tw = TabWriter::new(vec![]);
Bruce Springsteen\tBorn to Run
Bob Seger\tNight Moves
The Boss\tDarkness on the Edge of Town

let written = String::from_utf8(tw.into_inner().unwrap()).unwrap();

assert_eq!(&written, "
Bruce Springsteen  Born to Run
Bob Seger          Night Moves
Metallica          Black
The Boss           Darkness on the Edge of Town

You can see an example of real use in my CSV toolkit.

Simple example of command line utility

[andrew@Liger tabwriter] cat sample | sed 's/   /\\t/g'
abcmnoxyz\tmore text

[andrew@Liger tabwriter] ./target/tabwriter < sample
a          b           c
abc        mnopqrstuv  xyz
abcmnoxyz  more text

a   b   c

Notice that once a column block is broken, alignment starts over again.


The API is fully documented with some examples: http://burntsushi.net/rustdoc/tabwriter/.


This crate works with Cargo. Assuming you have Rust and Cargo installed, simply check out the source and run tests:

git clone git://github.com/BurntSushi/tabwriter
cd tabwriter
cargo test

You can also add tabwriter as a dependency to your project's Cargo.toml:

tabwriter = "1"

Dealing with ANSI escape codes

If you want tabwriter to be aware of ANSI escape codes, then compile it with the ansi_formatting feature enabled.

Minimum Rust version policy

This crate's minimum supported rustc version is 1.34.0.

The current policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if crate 1.0 requires Rust 1.20.0, then crate 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, crate 1.y for y > 0 may require a newer minimum version of Rust.

In general, this crate will be conservative with respect to the minimum supported version of Rust.

*Note that all licence references and agreements mentioned in the tabwriter README section above are relevant to that project's source code only.