JSONL Validator
Validate your JSONL (JSON Lines) files instantly. Check every line for correct JSON syntax. 100% client-side, your data never leaves your browser.
Input JSONL
Drop a .jsonl file here, or click to browse
Supports .jsonl, .ndjson, .json, .txt
Validation Result
Paste or drop JSONL content to validate
Error reference: what broke and how to fix it
Nearly every invalid JSONL file fails for one of six reasons. This table maps the error you'll see to the actual byte-level cause and the fastest fix — per RFC 8259, JSON is strict about all of these, and JSONL adds the one-record-per-line rule on top:
| Broken line looks like | What's wrong | Fix |
|---|---|---|
| {"a": 1,} | Trailing comma — legal in JavaScript, illegal in JSON | Remove the comma before } or ] |
| {'a': 1} | Single quotes — JSON strings require double quotes | Replace ' with " on keys and string values |
| {"note": "line one | Unescaped newline inside a string splits the record across lines | Escape it as \n so the record stays on one line |
| {"a": 1} | UTF-8 BOM glued to the first record | Save without BOM, or strip the first three bytes |
| {"a": 1} {"b": 2} | Two records on one line — the parser sees trailing garbage | Put every record on its own line |
| (blank line) | Strictly speaking not a record; some parsers error, some skip | Delete blank lines, or configure consumers to skip them |
How to Validate JSONL Files
JSONL validation checks each line of your file to ensure it contains valid JSON. Each line must be a complete, parseable JSON value — typically a JSON object.
Our validator reads your JSONL file entirely in the browser. No data is uploaded to any server. Simply paste your JSONL text or drag and drop a file, and validation results appear instantly.
Lines with errors are highlighted with their line number and the specific error message. You can copy the validation report to share with your team or use it to fix the issues.
Checking OpenAI fine-tuning files
A fine-tuning upload fails if any line breaks OpenAI's chat format. Switch the checker above to OpenAI fine-tuning format to find every problem line before you upload. For each line it checks:
- a "messages" array that is present and not empty
- a role on every message: system, user, assistant or tool
- content given as a string or a list of content parts (an assistant message that only calls a tool may leave it out)
- at least one assistant message, which is what the model learns from
- a "weight" of 0 or 1, used only on assistant messages
- lines in the legacy prompt/completion format or in preference (DPO) format, which need a different setup
It also counts examples and messages, warns when a file has fewer than the 10 examples OpenAI requires, and gives a rough token estimate so you can judge the size of a training run. For the format itself, see the OpenAI JSONL format guide.
Common Errors & Solutions
Trailing Commas in JSON Objects
A trailing comma after the last key-value pair in a JSON object (e.g., {"name":"Alice",}) is not valid JSON. Remove the comma after the last property on each line to fix this common syntax error.
Unquoted Property Keys
JSON requires all property keys to be wrapped in double quotes. Keys like {name:"Alice"} will fail validation. Ensure all keys use double quotes: {"name":"Alice"}.
Invalid Escape Sequences in Strings
JSON only supports specific escape sequences (\n, \t, \", \\, etc.). Invalid sequences like \x or \' will cause parse errors. Use the correct JSON escape sequences or encode special characters as Unicode (\uXXXX).
Validating in CI and on the command line
Use these commands to check one JSON value per line before a pipeline runs. They read one line at a time, so memory use depends on the largest record rather than the whole file. Blank lines are rejected; a final newline is optional.
# jq: parse each line and stop on the first error; empty needs no -e
jq -R 'try (
if startswith("\uFEFF") then error("UTF-8 BOM is not allowed")
else fromjson end | empty
) catch halt_error(1)' data.jsonl && echo OK
# Python: reject non-standard constants and report the first broken line
python3 - <<'PYTHON'
import json
import sys
def reject_constant(value):
raise ValueError(f"Invalid JSON constant: {value}")
with open("data.jsonl", "r", encoding="utf-8") as source:
for line_number, line in enumerate(source, 1):
try:
json.loads(line, parse_constant=reject_constant)
except ValueError as error:
sys.exit(f"Line {line_number}: {error}")
print("OK")
PYTHONThese checks do not enforce required fields, field types, or OpenAI training-data rules; use schema validation for those. jq accepts some non-standard number literals, including NaN and Infinity. Use the Python example when those must be rejected.
What is JSONL Validation?
JSONL validation is the process of checking that each line in a JSONL file contains syntactically correct JSON. This is critical before using JSONL files for machine learning training, API batch operations, or data pipeline processing.
Common issues that validation catches include: missing or extra commas, unquoted keys, trailing commas, mismatched brackets, invalid escape sequences, and encoding problems like BOM characters.
Common Use Cases
- Data Quality Assurance
- Validate JSONL exports before importing into databases or analytics platforms to prevent data corruption.
- ML Dataset Validation
- Check OpenAI fine-tuning datasets and Hugging Face training data for format correctness before uploading.
- Debugging Data Pipelines
- Identify malformed lines in JSONL log files and streaming data outputs.
- Pre-upload Verification
- Validate JSONL files before uploading to APIs that require strict format compliance.
- CI/CD Pipeline Validation
- Integrate JSONL validation as a step in CI/CD pipelines to catch malformed data files before they reach production environments.
- Schema Consistency Checking
- Validate that all lines in a JSONL file parse correctly and visually inspect whether records follow a consistent schema structure.
Frequently Asked Questions
What does JSONL validation check?
JSONL validation checks that each non-empty line in your file is syntactically valid JSON. It verifies proper bracket matching, correct string quoting, valid escape sequences, and overall JSON structure.
Is my data safe during validation?
Yes. All validation happens locally in your browser. No data is sent to any server. Your JSONL content never leaves your device.
Can I validate large JSONL files?
Yes. The validator can handle large files as it processes each line independently. For very large files (100MB+), validation may take a few seconds.
What should I do if validation fails?
Review the error details for each invalid line. Common fixes include adding missing quotes, removing trailing commas, and ensuring proper bracket matching. You can also use our JSONL Formatter to help identify formatting issues.
Does the validator check for consistent schemas across lines?
The validator checks JSON syntax only, not schema consistency. Each line is validated independently to ensure it is valid JSON. For schema validation, you would need a JSON Schema validator on top of the syntax check.
Can I validate NDJSON or JSON Lines files with different extensions?
Yes. The validator accepts .jsonl, .ndjson, .json, and .txt file extensions. The content is treated the same regardless of extension — each non-empty line is validated as JSON.
How are empty lines and whitespace-only lines handled?
Empty lines and lines containing only whitespace are automatically skipped during validation. They are not counted as errors and do not appear in the validation report. This follows the JSONL specification.
Can this tool fix invalid JSONL automatically?
The validator identifies and reports errors but does not auto-fix them. Automatic fixing could change the intended data. Use the error details to manually correct each issue, then re-validate to confirm all lines pass.
Related tools & guides
Format and beautify JSONL files with proper indentation. Makes debugging and reviewing data easier.
Complete guide to preparing JSONL files for OpenAI. Covers fine-tuning data format, Batch API requests, common mistakes, and validation tips.
Learn how to validate JSONL files using JSON Schema. Covers Python jsonschema, Node.js Ajv, CLI tools, CI/CD automation, and fixing common validation errors.
Learn how to structure JSONL files for OpenAI's Batch API. Request format, response parsing, and complete workflow with code examples.
Split large JSONL files into smaller chunks by line count or file size. Perfect for batch API limits and parallel processing.