How to Validate JSON Before Production
Broken JSON takes down deploys and APIs. Learn a practical validation workflow with examples from CI, webhooks, and config files.
Invalid JSON has a talent for arriving five minutes before a release. A trailing comma in settings.json, a single-quoted key in an API fixture, or a truncated copy from a log viewer - and your pipeline stops, your webhook handler crashes, or your mobile app cannot parse config. Validating JSON before production is cheap insurance.
This guide covers a practical workflow, real failure stories, and free tools that run in your browser.
Syntax vs schema validation
Two layers matter:
- Syntax - Is the text valid JSON at all? (JSON Validator)
- Schema - Does the document match an expected shape? (JSON Schema Validator)
Syntax fails on commas, quotes, and brackets. Schema fails when required fields are missing or types are wrong ("age": "thirty" instead of 30).
Always fix syntax first. Formatting with JSON Formatter only works on valid input.
Real production scenarios
Webhook payloads
Scenario: Stripe, GitHub, or Shopify sends POST bodies your service parses with JSON.parse. A vendor test event includes NaN or unquoted keys in a sandbox (rare but memorable).
Workflow: Save failing payload to a file. Validate syntax. If valid, validate against your OpenAPI or JSON Schema contract before patching the handler.
CI config and IaC
Scenario: Terraform plan JSON export, CloudFormation parameters, or a custom CI matrix file breaks the build.
Workflow: Paste into validator, fix line/column from the error, commit, re-run pipeline. Faster than grep-ing for trailing commas.
Mobile app remote config
Scenario: Marketing updates Firebase remote config JSON from a spreadsheet export. App crashes on launch in staging.
Workflow: Schema-validate required keys (min_app_version, feature_flags) before publish. Syntax check catches paste errors; schema catches missing flags.
Log pipeline debugging
Scenario: Log shipper expects JSON lines; one service prints pretty-printed multi-line JSON, breaking NDJSON consumers.
Workflow: Validate each line independently. Multi-line pretty JSON is valid JSON as a document but invalid as NDJSON - different tool, same discipline.
Step-by-step validation checklist
- Copy the exact bytes - no ellipses, no "..." truncation
- Run JSON Validator - read first error line/column
- Fix and re-validate until clean
- Optional: JSON Schema Validator against contract
- Format for review with JSON Formatter before PR
- Store fixtures in version control for regression tests
Common errors and fixes
| Error | Typical cause | Fix |
|---|---|---|
| Unexpected token | Trailing comma, comments | Remove comma; strip // comments (not valid JSON) |
| Unexpected end | Truncated paste | Copy full payload |
| Expected property name | Single-quoted keys | Use double quotes |
| NaN / Infinity | JavaScript object literal | Replace with null or strings |
Remember: JSON is not JavaScript. undefined, functions, and unquoted keys are invalid.
Automating beyond the browser
Browser tools excel for ad-hoc debugging. For pipelines, add:
jq empty file.jsonin shell scriptsajv validate -s schema.json -d data.jsonin CI- Unit tests that load golden fixtures
Utilitoo complements automation - engineers still paste one-off payloads during incidents.
Privacy
Webhook bodies contain PII and secrets. Utilitoo validates locally in the browser - payloads are not uploaded for validation. Rotate credentials if they were ever exposed in a shared channel.
Putting it into team practice
Add a note to your runbook: "paste failing payload into validator before escalating." New hires learn faster when the checklist names a concrete tool. Keep golden invalid fixtures (trailing-comma.json, truncated.json) in the repo so CI and humans share the same examples.
Summary
Validate JSON syntax before every risky deploy, schema when contracts matter, and format for human review last. Real teams catch errors in webhooks, CI configs, and remote settings this way. Start with JSON Validator, escalate to JSON Schema Validator when structure is part of the contract.
Try these tools
- JSON Validator - Validate JSON syntax and find errors instantly.
- JSON Schema Validator - Validate JSON data against a JSON Schema.
- JSON Formatter - Format and beautify JSON online instantly.
