Blog
Wild & Free Tools

Format JSON on Linux Without Installing jq

Last updated: April 2026 6 min read

Table of Contents

  1. Option 1: Browser Tool (No Install)
  2. Option 2: Python (Almost Always Available)
  3. Option 3: jq (Best for Complex JSON Work)
  4. Option 4: Node.js
  5. Comparing the Four Approaches
  6. Frequently Asked Questions

You have JSON on a Linux machine and you want to format it. Four ways to do it — from a browser tab to the terminal — depending on what tools you have available and how often you need to do this.

The browser approach (using WildandFree JSON Formatter) requires zero installation. The terminal approaches use tools you probably already have installed.

Option 1: Browser Tool — No Installation Required

If you have a browser and your JSON is small enough to copy-paste, this is the fastest path. Open wildandfreetools.com/developer-tools/json-formatter/, paste your JSON, click Format. Done in 10 seconds, works on any Linux distro, no packages to install.

This approach is particularly useful when:

The tool runs in your browser, so your JSON never hits any external server. Fine for sensitive data.

Option 2: Python — Already on Almost Every Linux System

Python 3 includes a built-in JSON formatter you can use from the command line without installing anything:

echo '{"name":"Alice","age":30}' | python3 -m json.tool

Or to format a file:

python3 -m json.tool input.json

To format a file and write the output back (overwrite in place):

python3 -m json.tool input.json output.json

Python 2 also works: python -m json.tool — though you shouldn't be running Python 2 in 2026.

The output uses 4-space indentation by default. If you want 2-space indentation: python3 -c "import sys, json; print(json.dumps(json.load(sys.stdin), indent=2))"

Sell Custom Apparel — We Handle Printing & Free Shipping

Option 3: jq — The Right Tool for Complex JSON Work

jq is the gold standard for JSON processing on the command line. Install it if you work with JSON regularly:

sudo apt install jq (Debian/Ubuntu)
sudo yum install jq (RHEL/CentOS)
sudo dnf install jq (Fedora)
brew install jq (macOS with Homebrew)

Format JSON from stdin: echo '{"name":"Alice"}' | jq .

Format a file: jq . input.json

Minify JSON (compact output): jq -c . input.json

jq goes far beyond formatting — you can filter, transform, query, and reshape JSON from the command line. If you're piping JSON through shell scripts, jq is essential. For just formatting, Python is equally good and requires no installation on most systems.

Option 4: Node.js — One-Liner for Developers Who Already Have It

If Node.js is installed, you can format JSON with a one-liner:

node -e "process.stdin.resume();let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>console.log(JSON.stringify(JSON.parse(d),null,2)));" < input.json

That's verbose. A shorter version using piping:

cat input.json | node -e "const s=[];process.stdin.on('data',d=>s.push(d));process.stdin.on('end',()=>console.log(JSON.stringify(JSON.parse(s.join('')),null,2)))"

Or create a small script fmt-json.js you can call repeatedly. Honestly, for this specific use case, Python's one-liner is much cleaner. Use Node.js for JSON formatting only if you're already in a Node project context where Python isn't the obvious choice.

Quick Comparison — Which Approach to Use

ApproachInstall Required?Best For
Browser (WildandFree)NoQuick formatting when pasting from a source
Python json.toolNo (Python 3 preinstalled)Command-line formatting without extra packages
jqYes (apt/yum/brew)Scripting, filtering, transforming JSON in pipelines
Node.jsYes (if not on system)Node.js projects, already in JS context

Start with the browser tool for one-off tasks. Use Python for scripting when jq isn't available. Install jq when you process JSON regularly in the terminal — the investment pays off quickly.

Try It Free — No Signup Required

Runs 100% in your browser. No data is collected, stored, or sent anywhere.

Open Free JSON Formatter

Frequently Asked Questions

How do I format JSON in a Linux terminal without any tools?

Python 3 is preinstalled on most Linux systems and includes a JSON formatter: python3 -m json.tool input.json. No additional installation required.

How do I pretty print JSON from a curl response in Linux?

Pipe the curl output through python3 -m json.tool: curl -s https://api.example.com/data | python3 -m json.tool. Or with jq installed: curl -s https://api.example.com/data | jq .

Is jq available on all Linux distributions?

jq is available in the package repositories of all major Linux distributions (Debian, Ubuntu, RHEL, Fedora, Arch, Alpine, etc.), but it isn't installed by default on most of them. Run the package manager command for your distro to install it.

Launch Your Own Clothing Brand — No Inventory, No Risk