package print-table

  1. Overview
  2. Docs
Simple Unicode/ANSI and Markdown text table rendering

Install

dune-project
 Dependency

Authors

Maintainers

Sources

print-table-0.1.3.tbz
sha256=38a408c56b7cdb379bfdac0d14791cbffb7bc27cde23bf869e0600c1cd3f1173
sha512=08c8acb8d1b85b240fbe6876e3f378110b8dc1efdd216c6a24d5f5c270fbd09c1bc7f2b9c4f08f6f44aa09c343e70b83bfb3c46d9acf51205cda5f3870161406

Description

print-table provides a minimal library for rendering text tables with Unicode box-drawing characters and optional ANSI colors, or as GitHub-flavored Markdown.

The API is straightforward and declarative, designed for readable tables in command-line tools, tests, and tutorials.

This library has taken some inspiration from 2 existing and more feature-complete libraries, which we link to here for more advanced usages: see printbox and ascii_table.

Tags

table markdown

Published: 25 Jan 2026

README

CI Status Coverage Status OCaml-CI Build Status

Print_table provides a minimal library for rendering text tables with Unicode box-drawing characters and optional ANSI colors:

# let columns =
  Print_table.O.
    [ Column.make ~header:"Name" (fun (name, _) -> Cell.text name)
    ; Column.make ~header:"Score" ~align:Right (fun (_, score) ->
        Cell.text (Int.to_string score))
    ]
val columns : (string * int) Print_table.Column.t list = [<abstr>; <abstr>]

# let rows = [ "Alice", 10; "Bob", 3 ] ;;
val rows : (string * int) list = [("Alice", 10); ("Bob", 3)]

# print_endline (Print_table.to_string_text (Print_table.make ~columns ~rows))
┌───────┬───────┐
│ Name  │ Score │
├───────┼───────┤
│ Alice │    10 │
│ Bob   │     3 │
└───────┴───────┘

- : unit = ()

Or as GitHub-flavored Markdown:

# print_endline (Print_table.to_string_markdown (Print_table.make ~columns ~rows))
| Name  | Score |
|:------|------:|
| Alice |    10 |
| Bob   |     3 |

- : unit = ()

which is rendered natively by GitHub like this:

Name

Score

Alice

10

Bob

3

Code Documentation

The code documentation of the latest release is built with odoc and published to GitHub pages here.

Acknowledgments

This library has taken some inspiration from 2 existing and more feature-complete libraries, which we link to here for more advanced usages.

Dependencies (2)

  1. ocaml >= "4.14"
  2. dune >= "3.17"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. crs >= "0.0.20250914"

Conflicts

None