DEV Community

arenasbob2024-cell
arenasbob2024-cell

Posted on • Originally published at viadreams.cc

JSON Prettifier: Format Minified JSON for Readability

Working with minified JSON from APIs? Here's how to quickly format it for readability.

Why Prettify JSON?

API responses and config files are often minified to save bandwidth:

{"name":"John","age":30,"address":{"city":"NYC","zip":"10001"},"tags":["dev","js"]}
Enter fullscreen mode Exit fullscreen mode

Prettified JSON is much easier to read and debug:

{
  "name": "John",
  "age": 30,
  "address": {
    "city": "NYC",
    "zip": "10001"
  },
  "tags": [
    "dev",
    "js"
  ]
}
Enter fullscreen mode Exit fullscreen mode

Quick Methods

Command Line

echo '{"a":1}' | python -m json.tool
echo '{"a":1}' | jq .
Enter fullscreen mode Exit fullscreen mode

JavaScript

const formatted = JSON.stringify(data, null, 2);
Enter fullscreen mode Exit fullscreen mode

Online Tool

Use the free JSON Prettifier for instant formatting with:

  • Syntax validation
  • 2-space indentation
  • Copy to clipboard
  • No data sent to servers

Related Tools

Top comments (0)