CS

Loading workspace...

Preparing your tools

Guide

Validate JSON Syntax Before Calling an API

Validate JSON syntax in the browser, fix trailing commas and data types, and distinguish valid JSON from schema-valid data.

Introduction

Introduction

JSON is strict about quotes, commas and data types. A configuration fragment that looks almost correct may still fail in an API request or build pipeline. JSON Validator checks JSON text in the browser using the JavaScript JSON parser, helping identify syntax errors before the data is submitted elsewhere.

Validation means the text can be parsed as JSON. It does not prove that an API accepts its fields or that the values satisfy a business schema. Those are separate checks.

Step-by-step guide

1

Step 1

Open [JSON Validator](/tools/json-validator) and paste the JSON text from your local file or test payload.

2

Step 2

Run the validation action. If the parser reports an error, inspect the location and nearby syntax.

3

Step 3

Correct the source and validate again until it parses.

4

Step 4

Confirm the expected field types, such as a number versus a quoted numeric string.

5

Step 5

Test the valid JSON against the receiving API or JSON Schema, if one is supplied by the service.

Benefits

  • ✓ Validate the complete payload before sending an API request.
  • ✓ Keep booleans, numbers, strings, arrays and null values in the expected types.
  • ✓ Check the receiving application's schema after syntax validation.
  • ✓ Use synthetic examples when sharing errors or reproductions.
  • ✓ Preserve an original copy before reformatting or modifying important JSON documents.

Best practices

  • • Validate the complete payload before sending an API request.
  • • Keep booleans, numbers, strings, arrays and null values in the expected types.
  • • Check the receiving application's schema after syntax validation.
  • • Use synthetic examples when sharing errors or reproductions.
  • • Preserve an original copy before reformatting or modifying important JSON documents.

More details

Validate a small payload

  1. Open JSON Validator and paste the JSON text from your local file or test payload.
  2. Run the validation action. If the parser reports an error, inspect the location and nearby syntax.
  3. Correct the source and validate again until it parses.
  4. Confirm the expected field types, such as a number versus a quoted numeric string.
  5. Test the valid JSON against the receiving API or JSON Schema, if one is supplied by the service.

The browser implementation enforces an input-size limit and a nesting-depth limit to avoid processing unbounded text. The current JSON utilities limit input to 1,000,000 characters and nesting to 256 levels.

Example: fixing a trailing comma

This fragment is invalid JSON:

{"name":"demo","enabled":true,}

Remove the comma after true:

{"name":"demo","enabled":true}

Unlike some JavaScript object literals, standard JSON does not allow trailing commas, comments or unquoted property names. Correcting those issues is a syntax fix, not a change to the application requirements.

Valid syntax versus valid meaning

The JSON {"limit":"10"} is syntactically valid, yet a service expecting a numeric limit may reject it because the value is a string. Likewise, valid JSON containing an unknown key may be rejected by a strict API.

Use JSON Formatter to display complex nested values with indentation, then compare them to the receiver's documented schema. Use JSON Diff when the question is which keys or array positions changed between two valid documents.

Unicode and precision concerns

JSON can represent Unicode text and escaped characters, but differences in normalization or a receiving application's database constraints can still matter. JavaScript JSON parsing also follows its own number representation; very large integers may lose precision when treated as ordinary JavaScript numbers. Do not use a text validator as proof that every numeric identifier will survive downstream processing unchanged.

Sensitive API tokens and personal details should not be pasted into public screenshots or issue trackers. Prefer synthetic values for reproducing a parsing problem.

Troubleshooting

If validation fails, check double quotes, matching braces/brackets, commas between fields and proper escaping of backslashes. If it succeeds but the API still rejects a request, inspect the expected schema, required properties, authorization and endpoint requirements. If the input exceeds the browser limit, validate smaller focused sections locally.

Related tools

Continue your workflow with these matching tools.

Related, practical walkthroughs for the tools used in this guide.

Ready to run this workflow?

Upload your file and apply these settings in under a minute.