Home Guides Text Guides

Text Guides

How to Format and Validate JSON

Format and validate JSON with practical examples, common syntax errors, schema limits, privacy cautions and a browser-based Tervilo tool.

In this guide Step-by-step explanations, practical examples and useful context to help you complete the task confidently.

JSON is easy to write by hand and surprisingly easy to break with one missing quote, comma or bracket. When a configuration file, API response or request body stops parsing, a formatter and validator can quickly tell you whether the structure is valid and make the data easier to inspect.

What formatting and validation do

Formatting changes how valid JSON is displayed. It can add indentation and line breaks so nested objects and arrays are easier to read. Validation checks whether the text follows JSON syntax. These are different jobs: formatting does not repair invalid syntax, and valid JSON does not automatically mean the data has the structure an application expects.

A small JSON example

{"name":"Aisha","active":true,"roles":["editor","reviewer"]}

Formatted, the same data is easier to inspect:

{
  "name": "Aisha",
  "active": true,
  "roles": [
    "editor",
    "reviewer"
  ]
}

Validate JSON with Tervilo

  1. Open the Tervilo JSON Formatter & Validator.
  2. Paste the JSON.
  3. Format the text when you want a readable layout.
  4. Run validation if you need to confirm syntax.
  5. Correct the reported problem and validate again.

Common JSON errors

  • Missing commas between object properties or array values.
  • Using single quotes instead of JSON's required double quotes for strings.
  • Leaving a trailing comma after the last property or array item.
  • Missing a closing brace or bracket.
  • Using an unquoted property name where a JSON string is required.
  • Writing a value such as undefined that is not a JSON data type.

JSON is case-sensitive

Property names such as name and Name are different keys. A document can be perfectly valid JSON while still failing an application's expectations because the wrong property name was used.

Valid JSON is not the same as valid application data

A validator can confirm syntax but usually cannot know your API contract. For example, "age":"42" can be valid JSON even when an application expects "age":42. Likewise, a required property can be missing while the JSON remains syntactically valid. After syntax validation, check the schema or API documentation that defines what the application expects.

Formatting vs minifying

Pretty formatting helps people read and debug JSON. Minifying removes unnecessary whitespace and is useful when a compact payload is preferred. It does not make the JSON “more valid”; it only changes presentation.

Be careful with copied JSON

JSON copied from a web page, document or email can contain typographic quotation marks or invisible formatting characters. Paste the exact payload into a validator and inspect the error location rather than manually guessing.

Security and privacy

Before pasting JSON into any online service, check whether it contains API keys, access tokens, personal information or confidential business data. Remove secrets that are not required for debugging. A formatter should help with syntax without becoming a reason to expose credentials.

Quick checklist

  • □ Strings use double quotes.
  • □ Properties and array values are separated correctly.
  • □ Braces and brackets are balanced.
  • □ The JSON is syntactically valid.
  • □ The data also matches the application's schema or contract.
  • □ Secrets and sensitive values were removed before sharing.

Quick answer

Use a JSON formatter to make valid JSON easier to read and a validator to catch syntax errors. After the syntax passes, check the application's expected schema because valid JSON can still contain the wrong data types, missing fields or incorrect property names.

You've reached the end

Use the related tools, FAQs and next guides below to continue from the topic you just learned.

Use the solution

Try the Tervilo Tools

Finish the task with a practical Tervilo tool related to this guide.

Continue learning

Related Guides

Explore the next practical guide without leaving Tervilo.

Learn more

Related Articles

Understand the wider topic with an informative Tervilo article.