ToolDeck

JSON প্রিটি প্রিন্ট

পাঠযোগ্যতার জন্য কাস্টমাইজযোগ্য ইন্ডেন্টেশন সহ JSON প্রিটি প্রিন্ট করুন

একটি উদাহরণ চেষ্টা করুন

ইনপুট

প্রিটি-প্রিন্টেড আউটপুট

স্থানীয়ভাবে চলে · গোপন তথ্য পেস্ট করা নিরাপদ
প্রিটি-প্রিন্টেড JSON এখানে দেখাবে…

What is JSON Pretty Print?

JSON pretty print transforms compact, hard-to-read JSON into a neatly indented, multi-line format. While machines happily parse single-line JSON, humans need structure — visual hierarchy, aligned brackets, and consistent indentation — to understand and work with complex data quickly.

Before · json
After · json
{"user":"alice","role":"admin","permissions":["read","write"],"active":true,"lastLogin":1717200000}
{
  "user": "alice",
  "role": "admin",
  "permissions": [
    "read",
    "write"
  ],
  "active": true,
  "lastLogin": 1717200000
}

Why Pretty Print JSON?

Raw JSON from APIs, databases, and log files is often minified to save bandwidth. Pretty printing restores the human-readable structure you need to debug, review, and understand data without straining your eyes.

🔍
Faster Debugging
Spot missing fields, wrong values, and structural errors in seconds instead of parsing a wall of text character by character.
👥
Cleaner Code Reviews
Reviewing JSON config changes in pull requests is dramatically easier with proper indentation — reviewers can focus on what changed.
🔌
API Inspection
When exploring a new API, pretty-printed responses let you understand the data model and nesting structure at a glance.
📝
Documentation & Sharing
Pretty-printed JSON is ready to paste into docs, wikis, tickets, and Slack without anyone needing to mentally parse it.

Choosing Your Indentation

Both 2 and 4 spaces are widely used. The right choice usually comes down to your team's style guide or personal preference.

2 Spaces
The most popular choice in JavaScript and JSON communities. Keeps files compact while still being readable. Used by npm, ESLint, and most JS style guides.
4 Spaces
Common in Python, Java, and C# projects. Provides more visual breathing room and is often preferred for deeply nested structures.

Common Use Cases

Debugging API Responses
Paste a raw API response and instantly see the full data structure, nested objects, and array contents in a readable layout.
Reading Config Files
Configuration stored in minified JSON becomes trivial to read and edit once pretty-printed — no more hunting for that one key.
Log Analysis
Structured logs often contain JSON payloads. Pretty printing individual log entries makes root-cause analysis much faster.
Developer Documentation
Provide clear, indented JSON examples in your API docs so developers can understand request and response shapes immediately.
Data Exploration
When working with an unfamiliar dataset, pretty printing reveals the full schema — fields, types, and nesting — without reading docs first.
Testing & QA
Comparing expected vs actual JSON in test failures is far easier with consistent indentation and line-by-line structure.

Pretty Print in Your Terminal

You don't always need a browser tool. These commands pretty print JSON directly in your terminal without any installation beyond the tools you likely already have.

Python
echo '{"a":1}' | python3 -m json.tool
Node.js
node -e "console.log(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')),null,2))"
CLI (jq)
cat data.json | jq .
curl + jq
curl -s https://api.example.com/data | jq .

Frequently Asked Questions

What is JSON pretty printing?
JSON pretty printing (also called JSON formatting or JSON beautifying) converts compact, minified JSON into a human-readable layout with consistent indentation and line breaks. It makes nested structures, arrays, and key-value pairs easy to scan and debug.
Does pretty printing change the data?
No. Only whitespace is added — no data, keys, values, or ordering is modified. A pretty-printed JSON file is semantically identical to the original.
Which is better: 2 spaces or 4 spaces?
Neither is objectively better. 2 spaces is more compact and is the default in many JavaScript tools. 4 spaces provides more visual separation. Use whichever your team's style guide specifies, or 2 spaces if you have no preference.
Can I pretty print invalid JSON?
No — the input must be valid JSON first. If you have trailing commas, single quotes, or comments (JSONC/JSON5), convert to standard JSON before pretty printing.
How do I pretty print JSON in my browser's DevTools?
In Chrome/Firefox DevTools, click the {} button at the bottom of any network response panel to auto-format it. You can also run JSON.stringify(obj, null, 2) in the console to pretty print any JavaScript object.

সম্পর্কিত টুলস