Navigation

JSON Validator

Deeply analyze, format, repair, and validate your JSON data with detailed statistics, error reports, auto-fix, and fullscreen editing.

Last updated:

The JSON Validator is more than just a syntax checker; it is a comprehensive diagnostic environment for JSON data. Whether you are debugging a complex API response, preparing configuration files, or auditing large datasets, our validator provides the tools needed to ensure structural integrity and compliance with JSON standards. It offers real-time syntax checking, an intelligent auto-repair engine, deep structural analysis, and professional formatting capabilities—all within a secure, client-side environment that guarantees 100% data privacy.

JSON Validator and Formatter

✨ Key Features

  • Real-time Validation: Errors are highlighted as you type with precise line and column markers.
  • Auto-Fix (Magic Repair): Automatically repair common syntax errors like missing commas, trailing commas, unquoted keys, and mismatched brackets.
  • Stateless Sharing: Share your JSON data and validation results with teammates via a compressed link.
  • Formatting: Pretty-print your JSON with one click to make it readable.
  • Minification: Instantly minify your JSON (remove all whitespace) for compact storage or API payloads.
  • Fullscreen Mode: Expand the validator to fill the entire viewport for complex files.
  • Dark/Light Theme: Adapts to your system preference or manual toggle.
  • Schema validation workflows: When JSON Schema mode is active, send the current input and schema to Pipelines to inspect, export, or expose schema-valid data as a mock API.

📊 Statistical Analysis

When your JSON is valid, the Validator displays a comprehensive stats panel:

StatDescription
LinesTotal line count of the formatted JSON
SizeFile size in bytes/KB/MB
KeysTotal number of keys across all objects
Max DepthDeepest level of nesting
ArraysTotal number of array structures
ObjectsTotal number of object structures
StringsCount of string values
NumbersCount of numeric values
BooleansCount of boolean values
NullsCount of null values

🏗️ Structure Information

The Validator automatically identifies and displays:

  • Root type: Whether the data is an Object, Array, or primitive.
  • Root keys: Lists all top-level keys for objects.
  • Total elements: For arrays, shows how many items are present.

⚠️ Common Issues Detection

Beyond syntax errors, the Validator detects and suggests fixes for:

  • Duplicate keys (which shadow each other in JSON).
  • Very deep nesting that may cause performance issues.
  • Very large string values that could indicate encoding problems.
  • Mixed types within arrays (informational warning).

🛠️ How to Use

  1. Navigate to the Validator Tool.
  2. Paste your JSON into the editor, or upload a file.
  3. Check the Status Banner — green means valid, red means errors detected.
  4. If errors exist, review the Errors Panel for exact locations and messages.
  5. Click Auto-Fix (magic wand ✨) to attempt automatic repair.
  6. Use the Format button to pretty-print.
  7. Click the Share (🔗) button to generate a shareable link of the current state.
  8. Review the Statistics panel for insights about your data structure.
  9. With a JSON Schema configured, choose Build validation workflow to create a rerunnable pipeline for inspection, export, or a schema-gated mock API.

⌨️ Actions

ActionDescription
FormatPretty-print with 2-space indentation
MinifyRemove all whitespace
CopyCopy the current editor content
DownloadSave the JSON to a local file
Auto-FixAttempt to repair common syntax errors
ClearReset the editor to empty

🧬 The Anatomy of a JSON Error

Understanding why a JSON document is invalid is the first step to fixing it. The DataLensia Validator identifies several categories of issues:

  • Syntactic Errors: These are hard failures like missing commas, mismatched brackets (e.g., closing an object with ]), or unquoted keys. These errors make the JSON unparseable by any standard library.
  • Contextual Warnings: Issues that are technically valid JSON but often unintended, such as duplicate keys. In most environments, the last occurrence of a duplicate key "shadows" previous ones, leading to subtle data loss bugs.
  • Formatting Violations: Use of single quotes (') instead of double quotes ("), or including comments (// or /* */). While some parsers (like JSON5) allow these, they violate the strict RFC 8259 specification.

✨ How Magic Repair Works

Auto-Fix reads the document's strings, values, and structure before applying repairs. The same button works across the tools, and all processing stays local.

  • Syntax repair: Recover missing commas and colons, trailing commas, unquoted keys, single or typographic quotes, malformed escapes, and recoverable missing closing brackets.
  • Fullwidth syntax: Recognize {}[]:,; as structural punctuation and " or ' as quotes. Characters inside string values and property names retain their spelling; letters and digits are not normalized.
  • Missing object opener: Restore an opening brace when the input starts with a quoted property and colon, has balanced inner containers, and ends with an unmatched outer closing brace.
  • Missing array opener: Restore [ in inputs such as 1,2,3] when at least one comma separates outer items, inner containers are balanced, and a single unmatched outer ] remains. Existing handling of consecutive arrays and NDJSON is preserved. Lone values such as 1] and unquoted prose such as hello,world] remain unchanged.
  • String preservation: URLs, literal comment markers, punctuation, Unicode, and control characters retain their content. Comments are removed only outside strings.
  • Text preservation: Large number tokens, duplicate keys, and property order survive repair. Tools that subsequently parse the result as JavaScript data still have JavaScript's numeric and duplicate-key limitations.
  • NDJSON support: Records stay in order, with one compact JSON value per line. Ordinary JSON keeps two-space indentation.
  • MongoDB BSON text: Convert ObjectId, ISODate, NumberInt, NumberLong, NumberDecimal, NumberDouble, Timestamp, BinData, UUID, RegExp, MinKey, MaxKey, and Code constructors to Canonical Extended JSON v2 type wrappers. Int32, Long, Decimal128, Double, and BSONRegExp aliases and an optional new are supported. Nested objects, arrays, and Code scopes share the same conversion rules.
  • Conservative recovery: Auto-Fix does not execute expressions, invent missing values, or return only a valid prefix. If the complete document cannot be repaired, its original text and validation error remain available for manual editing.

MongoDB conversion accepts explicit literal arguments appropriate to each constructor. Int64 and Decimal128 retain exact precision, including representable decimal scale such as 0.00. NumberDouble preserves its type, NaN, infinities and negative zero; numeric overflow, underflow or a conversion that would silently drop source precision is rejected. Timestamp(t, i) and Timestamp({t, i}) require both unsigned 32-bit components. BinData(subtype, base64) preserves binary bytes and the subtype; UUID uses subtype 04, and UUID binary payloads must contain 16 bytes. Invalid Base64 is rejected rather than decoded partially.

RegExp(pattern, flags), BSONRegExp(pattern, flags), and regex literals such as /timeout/i preserve patterns and sort valid BSON flags (i, m, s, u, x). Literal backslashes and escaped delimiters remain part of the pattern; slashes inside character classes are supported. RegExp(/pattern/i) retains the literal flags, and an explicit second flags argument replaces them. JavaScript-only flags are rejected rather than dropped; patterns are not executed. Code("source") and Code("source", {scope}) preserve code as text, including an explicitly empty scope, and never execute it. MinKey() and MaxKey() preserve their special types. In documents containing BSON constructors or regex literals, undefined becomes {"$undefined":true}, while untyped NaN and infinities become $numberDouble wrappers. Ordinary JSON Auto-Fix keeps its existing normalization of these literals to null.

ISODate timestamps require an explicit timezone; a date-only string is UTC. Invalid ObjectIds, UUIDs, numeric values, dates, malformed arguments, expressions and unsupported constructors leave the complete document unchanged. The output follows the MongoDB Extended JSON v2 representation for recognized BSON values; ordinary JSON number tokens and duplicate keys are preserved without inferring BSON types for them.

Immediately adjacent quoted strings in arrays, such as ["say ""hello"""], remain unchanged for manual correction because their intended boundaries are ambiguous.

Keys such as 007 and 2fa are quoted without changing their spelling. Unicode escapes in unquoted keys, such as \u006eame, are preserved when quoting the name. Numeric values still require a supported numeric form.

Integer values with an n suffix are converted to JSON number text without passing through JavaScript Number, including decimal, hexadecimal, binary, and octal forms. The suffix is retained in quoted strings and property names. Decimal fractions, exponents, and malformed separators with this suffix are rejected.

Simple JSONP wrappers and a single Markdown code block can also be unwrapped, including blocks labeled json, jsonc, json5, jsonl, or ndjson. Leading comments are supported before wrappers and their payloads. JSONP supports whitespace and comments around callback path dots and before the opening parenthesis, as in app /* route */ . callback ({a:1}). Callback names remain simple identifier paths with a single object or array argument. Trailing comments are supported, including around the optional terminal semicolon. Existing Python literals, undefined, and non-finite numeric literals are normalized to their JSON equivalents; undefined, NaN (including +NaN and -NaN), and infinities become null.

🐘 Validating Large-Scale Datasets

Handling JSON files that are several megabytes in size requires a specialized approach to maintain browser responsiveness:

  • Background Processing: File imports and Auto-Fix for larger documents use Web Workers, allowing the page to respond while repair runs. Editing the input cancels any pending repair.
  • Virtual Scrolling: The editor uses virtualization to only render the lines currently visible in the viewport, allowing it to handle massive files that would otherwise crash a standard text area.
  • Progressive Analysis: Statistical breakdowns are calculated incrementally, providing you with high-level insights (like size and line count) immediately while deeper metrics (like max depth and type distribution) are finalized in the background.

💡 Advanced Tip

You can use the Schema Generator to create a schema from a "good" sample of your data, and then use that schema in the Validator to ensure all future payloads match the required structure. This "Schema-First" approach is a best practice for maintaining data quality in large-scale applications.