Yantrasagaram

JSON Formatter & Validator

Working with raw JSON can be frustrating when the data arrives as a single compressed line or contains a subtle syntax error buried deep inside nested objects. This free JSON formatter lets you paste any JSON string and instantly beautify it with your choice of two-space or four-space indentation, making the structure easy to read and review. Need to shrink your payload before sending it over the wire? Switch to minify mode to strip every unnecessary whitespace character. If your JSON contains Base64-encoded values, decode them with the Base64 Encoder / Decoder. The built-in validator catches malformed JSON on the spot, pinpointing the exact line and character position of the error so you can fix it fast. Everything runs in your browser — your data never leaves your device. Whether you are debugging an API response, preparing a config file, or cleaning up test fixtures, this tool saves you time and hassle. For pattern-based searches within your JSON, try the Regex Tester.

How to Use This Tool

  1. Paste your raw JSON string into the input field. It can be minified, partially formatted, or copied straight from a terminal or API client.
  2. Choose an action: click Format to beautify with indentation, or Minify to compress into a single line.
  3. If the JSON is invalid, the tool highlights the exact error with line and character details. Fix the issue in the input and try again.
  4. Copy the formatted or minified output to your clipboard with the copy button and paste it into your editor, config file, or API request.

Examples

Minified JSON → Beautified Output

Input

{"name":"Alice","age":30,"roles":["admin","editor"],"active":true}

Output (2-space indent)

{
  "name": "Alice",
  "age": 30,
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}

Invalid JSON → Error Message

Input

{"name": "Alice", "age": 30,}

Error

Unexpected token } at position 28 — trailing comma after the last property is not allowed in JSON.

Beautified JSON → Minified Output

Input

{
  "status": "ok",
  "count": 42
}

Output (minified)

{"status":"ok","count":42}

What This Tool Is Useful For

Frequently Asked Questions

What makes JSON invalid?
The most common causes are trailing commas after the last item in an array or object, single quotes instead of double quotes around keys or string values, unquoted keys, missing commas between items, and unescaped special characters inside strings such as literal newlines or tabs.
What is the difference between formatting and minifying JSON?
Formatting (beautifying) adds indentation and line breaks so you can read the structure at a glance. Minifying does the opposite — it strips all optional whitespace to produce the smallest possible string. Use formatting when you need to inspect or edit the data; use minifying when you need to reduce payload size for network transfer or storage.
Is there a maximum size for the JSON I can paste?
There is no hard limit enforced by the tool. Because all processing runs in your browser, performance depends on your device. Most modern computers handle files up to several megabytes without any noticeable delay.
Does formatting change the data in any way?
No. Formatting only adds or removes whitespace characters. The actual data — keys, values, arrays, and nesting — stays identical. You can verify this by minifying the formatted output and comparing it to the original.
Can I format JSON with comments?
Standard JSON does not support comments. If your input contains JavaScript-style comments (// or /* */), the validator will flag it as invalid. You would need to remove comments before formatting. Some config formats like JSONC allow comments, but they are not valid JSON per the specification.

More Developer Tools

Need to encode a string? Base64 Encoder / Decoder. Need a secure credential? Password Generator. Share your formatted JSON via QR Code. Convert timestamps in your data with the Unix Timestamp Converter. Browse all utilities in the Developer Tools hub.

Related Tools