SEOLyzerPro

100% Free forever - No account required

Use 47 free online tools: meta tag and robots.txt generators, image and text tools, JSON converters, calculators and unit converters. No signup needed

JSON Formatter

Make minified JSON easy to read

JSON Formatter

What this tool does

The JSON Formatter takes JSON text and makes it easy to read by adding line breaks and indentation. It also helps you spot syntax errors, so you can fix broken data before it causes problems in an application or API. Developers, testers, data analysts and website owners use it when working with API responses, configuration files and exported data.

How to use it

  1. Paste your JSON into the input box.
  2. Click the format button.
  3. Read the neatly indented result, or look at the error message if the JSON is not valid.
  4. Copy the formatted JSON and use it in your project. Use Reset to clear the box.

What JSON is

JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is easy for people to read and for programs to parse, which is why most web APIs use it. Despite the name, it is used by many programming languages, not just JavaScript.

JSON data is built from a few simple parts:

  • Objects wrapped in curly braces, containing key and value pairs.
  • Arrays wrapped in square brackets, containing ordered lists of values.
  • Strings wrapped in double quotes.
  • Numbers, written without quotation marks.
  • Booleans, written as true or false.
  • null, representing an empty value.

Before and after

Unformatted JSON:

 
json
{"name":"Ali","age":30,"skills":["SEO","PHP"],"active":true}

Formatted JSON:

 
json
{
  "name": "Ali",
  "age": 30,
  "skills": [
    "SEO",
    "PHP"
  ],
  "active": true
}

Both versions contain exactly the same data. The formatted version is simply easier for a person to scan.

Common JSON errors and how to fix them

Problem Example Fix
Single quotes {‘name’: ‘Ali’} Use double quotes
Trailing comma {“a”: 1,} Remove the last comma
Unquoted key {name: “Ali”} Put the key in double quotes
Comments // note Remove them, as JSON does not allow comments
Missing comma {“a”: 1 “b”: 2} Add a comma between items
Unescaped quote “He said “hi”” Write “hi” inside the string
Invalid values undefined, NaN Use null or a valid number

If the tool reports an error at a certain line or position, check the characters just before that point, since the real mistake is often a little earlier.

JSON versus a JavaScript object

JSON looks similar to the object syntax used in JavaScript, but it is stricter. JavaScript allows single quotes, unquoted keys, comments and trailing commas in code, while JSON does not. Data copied from code, a console or a configuration file may therefore need cleaning before it becomes valid JSON.

Practical tips

  • Use two or four spaces for indentation, and stay consistent within a team.
  • Format JSON before comparing two versions, so that differences are easier to see.
  • Large files can be slow to display. Work with a smaller sample when you only need to inspect the structure.
  • Keep keys clear and consistent, such as “firstName” throughout instead of mixing styles.
  • When building APIs, validate JSON on both the sending and receiving side.

Privacy and safety

Do not paste passwords, API keys, access tokens, private keys or personal customer data into any online tool. Remove or replace sensitive values with dummy text before formatting. “Formatting happens in your browser and the data is not sent to our server.” 

Limits of this tool

The formatter checks and arranges the text you paste. It does not fix your data, check that values make sense for your application, or confirm that the data matches a particular schema. Very large JSON files may run slowly depending on your device and browser.

Frequently asked questions

Why does my JSON show an error?
The most common causes are single quotes, a trailing comma, missing quotes around keys, or a missing bracket.

Does formatting change my data?
No. Only whitespace is changed. The keys, values and order remain the same.

Can JSON have comments?
Standard JSON does not allow comments. Remove them before formatting.

What is the difference between formatting and minifying?
Formatting adds spaces and line breaks for readability. Minifying removes them to make the text smaller.

Can I convert JSON to CSV?
Yes. Use the JSON to CSV Converter for flat lists of records.

Related tools

JSON to CSV Converter, CSV to JSON Converter, Base64 Encode, Base64 Decode, URL Encode and Text Compare.