Skip to content

lucasepe/txtree

Repository files navigation

txtree

Visualize your data, branch by branch.

A command-line tool to visualize structured data as ASCII/Unicode trees.

It works both with plain indented text and JSON input.

Features

  • Convert JSON or indented text into a clean tree view
  • Multiple layout styles (right-aligned or top-down)
  • Optional alphabetical sorting of JSON object keys
  • Works with stdin or file inputs
  • Unicode connectors for readable output

Usage

txtree [flags] [file]

If no file is provided, txtree reads from stdin.

Examples

Pipe JSON from stdin

cat api-response.json | txtree

Read JSON from file

txtree api-response.json

Parse indented text

txtree -i text notes.txt

Use a different layout

txtree -l 3 data.json

Flags

-h    Show help
        (default: false)

-i    Input format (auto, text, json)
       ↳ (default: auto)

-l    Layout style:
        0 = right-center
        1 = right-top
        2 = right-bottom
        3 = top-down
        (default: 0)

-s    Sort keys alphabetically (JSON only)
        (default: false)

Note: -s applies only when -i=json. Sorting does not affect plain text mode.

Support

All tools are completely free to use, with every feature fully unlocked and accessible.

If you find one or more of these tool helpful, please consider supporting its development with a donation.

Your contribution, no matter the amount, helps cover the time and effort dedicated to creating and maintaining these tools, ensuring they remain free and receive continuous improvements.

Every bit of support makes a meaningful difference and allows me to focus on building more tools that solve real-world challenges.

Thank you for your generosity and for being part of this journey!

Donate with PayPal

How To Install

Using the install.sh script (macOS & linux)

Simply run the following command in your terminal:

curl -sL https://raw.githubusercontent.com/lucasepe/txtree/main/install.sh | bash

This script will:

  • Detect your operating system and architecture
  • Download the latest release binary
  • Install it into /usr/local/bin (requires sudo)
    • otherwise fallback to $HOME/.local/bin
  • Make sure the install directory is in your PATH environment variable

Manually download the latest binaries from the releases page:

Unpack the binary into any directory that is part of your PATH.

If you have Go installed

You can also install it using:

go install github.com/lucasepe/txtree@latest

Make sure your $GOPATH/bin is in your PATH to run txtree from anywhere.