DevTools Logo

Fine-tune JSONL Validator

Fine-tune JSONL Validator

Validate chat fine-tuning datasets and inspect local token estimates

Chat JSONL

About

Paste one chat fine-tuning sample per line to validate JSON syntax and message schemas. Switch between OpenAI and Anthropic formats to catch role and turn-order issues, then inspect deterministic line-level token estimates and role statistics.

Examples

Invalid JSON on line 2

Input
validateFinetuneJsonl('{"messages":[...]} \nnot-json\n {"messages":[...]}')
Output
errors: [{ line: 2, type: "invalid-json" }], totalSamples: 3

The bad line is pinpointed by number while valid lines still contribute role stats.

Anthropic alternation warning

Input
validateFinetuneJsonl('{...two user messages...}', "anthropic")
Output
warnings: [{ line: 1, type: "alternation" }], errors: []

Consecutive user messages warn about alternation but the sample still validates.

About this tool

Finetune JSONL Validator checks one-JSON-object-per-line training files with validateFinetuneJsonl(source, mode) (aliases buildFinetuneJsonlValidation, analyzeFinetuneJsonl): openai mode accepts system/user/assistant/tool roles, while anthropic mode requires user/assistant alternation with an optional separate system string and warns on consecutive same-role messages.

Every failure is tagged with a 1-based line number: unparseable lines become invalid-json, unknown roles become role errors, and structural problems become schema errors. An empty file reports an empty-file error at line 0, and a single trailing newline is ignored rather than counted as a sample.

Per-line stats (chars, estimatedTokens via chars/4, per-line roles) roll up into statistics with totalSamples, validSamples, invalidSamples, roleDistribution, and averageMessageLength. All validation runs in the browser, so training data never leaves the device.

How to use this tool

  1. Paste JSONL and pick a mode

    Put one sample object per line and choose openai or anthropic depending on the target API.

  2. Fix errors by line number

    Work through invalid-json, role, and schema errors using each finding's line field.

  3. Resolve anthropic warnings

    Reorder consecutive same-role messages into user/assistant alternation; keep system text in system.

  4. Check role distribution

    Confirm the role counts and average message length look right before exporting the file.

Use cases

Pre-flight before a fine-tune job

Catch malformed lines and bad roles locally instead of failing a billed training run.

Converting to Anthropic format

Surface non-alternating sequences and misplaced system roles before upload.

Auditing dataset balance

Use roleDistribution and average message length to spot skewed or truncated samples.

Common mistakes

Mistake:Using a role outside system/user/assistant/tool.

Fix:Anything else (e.g. developer, moderator) is a role error — map it to one of the four supported roles.

Mistake:Counting a trailing newline as a broken sample.

Fix:One final newline is stripped automatically; only genuinely non-empty bad lines produce errors.

Mistake:Putting system instructions inside messages for Anthropic.

Fix:Anthropic samples allow only user/assistant in messages — move system text to the top-level system string.

Frequently asked questions

What does this tool do?

It validates one-JSON-object-per-line training files with validateFinetuneJsonl (aliases buildFinetuneJsonlValidation, analyzeFinetuneJsonl): openai mode takes system/user/assistant/tool roles, anthropic mode enforces user/assistant alternation with a separate system string.

How are errors reported?

Every finding carries a 1-based line number — invalid-json for bad lines, role for unknown roles, schema for structural issues, and empty-file at line 0. A single trailing newline is ignored, not counted as a sample.

Is my training data uploaded or stored?

No. All validation and role-distribution stats run entirely in your browser.

What does the Anthropic alternation warning mean?

Consecutive same-role messages warn (e.g. two user turns in a row) without failing validation; reorder into user/assistant alternation and keep system text in system.

References & standards