Skip to content

Fine-Tuning JSONL Validator

Fine-Tuning JSONL Validator

Line-by-line schema, role-ordering, token-count, and duplicate detection for OpenAI and Anthropic SFT data.

Rows
3
Valid
3
Errors
0
Warnings
0
Duplicates
0
Total tokens
104
Avg tokens / row
35
Min / Max tokens
23 / 43
LineRolesTokensIssues
L1
systemuserassistant
38ok
L2
systemuserassistant
43ok
L3
userassistant
23ok

What This Tool Does

Validate supervised fine-tuning JSONL for OpenAI or Anthropic line by line in your browser: JSON parsing, message schema, role ordering, per-row token counts, and duplicate detection — no upload. The provider toggle matters: Anthropic expects the system prompt as a top-level system string, while OpenAI expects it as the first entry in the messages array.

Last updated:

This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.

Agent Invocation

Best Path For Builders

Browser workflow

Runs instantly in the browser with private local processing and copy/export-ready output.

Browser Workflow

This tool is optimized for instant in-browser execution with local data handling. Run it here and copy/export the output directly.

/fine-tuning-jsonl-validator/

For automation planning, fetch the canonical contract at /api/tool/fine-tuning-jsonl-validator.json.

How to Use Fine-Tuning JSONL Validator

  1. 1

    Pick the target provider

    Switch between OpenAI and Anthropic. The validator applies provider-specific schema rules — Anthropic puts system prompts at the top level while OpenAI inlines them as the first message.

  2. 2

    Paste your JSONL

    Drop one record per line into the input area. Empty lines are skipped. Use the Load sample button to see the expected structure for the selected provider.

  3. 3

    Review the per-row report

    Each row shows its detected roles, token count from gpt-tokenizer, and any schema or ordering issues. Filter the table by errors or warnings to focus on problem rows.

  4. 4

    Resolve duplicates and shape issues

    The summary panel surfaces duplicate groups, token distribution, and total error and warning counts. Fix consecutive-role warnings and missing assistant turns before kicking off a fine-tune job.

Frequently Asked Questions

Which providers are supported?
OpenAI Chat Completions fine-tune format and Anthropic Messages fine-tune format. Each provider has its own schema rules — system at top level for Anthropic, inline system for OpenAI — and the validator switches rule sets accordingly.
How are token counts computed?
Every row is encoded with gpt-tokenizer, the same BPE library used for GPT-4 family models. Counts are a close approximation for OpenAI fine-tunes and a reasonable upper bound for Anthropic; treat them as guidance, not a billing oracle.
How does duplicate detection work?
Each row is hashed against its full normalized JSON. Rows with identical hashes are flagged as duplicates of the first occurrence so you can prune them before training.
Does it send my data to a server?
No. Parsing, schema checks, tokenization, and hashing all run in your browser. The JSONL never leaves your device.
Can it catch role-ordering bugs?
Yes. The validator flags consecutive user messages, consecutive assistant messages, missing assistant targets, system messages out of position, and Anthropic rows that start with assistant instead of user.

How do I validate a JSONL file for OpenAI or Anthropic fine-tuning?

Pick the provider, paste the JSONL, and read the report. Every non-empty line is parsed as its own JSON object and checked against that provider's chat-format rules; failures show the exact line number, an issue code, and the raw row, so you fix the offending records instead of resubmitting a job blind.

Step by step

  1. Select OpenAI or Anthropic — the two formats differ, and a file that is valid for one fails the other.
  2. Paste your JSONL, or load the sample to see the expected shape.
  3. Read the summary: rows, valid, errors, warnings, duplicates, and token totals with average, minimum, and maximum per row.
  4. Click any row to expand its issue codes and raw JSON; filter the table to errors or warnings only.
  5. Fix the flagged lines in your dataset and re-paste until errors reach zero.

Format rules this validator enforces

Rule OpenAI Anthropic
Row shape JSON object with a messages array Same, plus optional top-level system string
System prompt Role system inside messages; warned if not first Top-level only — a system role inside messages is an error
Allowed roles system, user, assistant, tool, function user and assistant only
Minimum content At least 2 messages per row, including at least one assistant message — the training target
Ordering Consecutive same-role messages warn; last message expected to be assistant First message expected to be user; consecutive same-role messages warn

Rules as implemented in this validator's checks. Provider requirements evolve — treat the provider's own fine-tuning documentation as canonical for anything not listed here.

Which issues are errors and which are warnings?

Errors break the format: unparseable JSON, a missing messages array, an invalid role, missing content, or no assistant message at all. Warnings flag rows that load fine but train poorly: a system message that is not first, two same-role messages in a row, a final message that is not from the assistant, and exact duplicates of an earlier line — duplicate rows skew the loss toward repeated examples.

How are the token counts computed?

With the gpt-tokenizer o200k encoding, loaded lazily in the browser because its BPE table is around 2 MB. Until it finishes loading, counts fall back to a characters-divided-by-four estimate, then recompute exactly. Use the min/max spread to spot outlier rows — a single giant example can dominate a training epoch or exceed the per-example context limit.

Is my training data uploaded?

No. Parsing, validation, and token counting all run in the page; nothing is transmitted or stored. Fine-tuning datasets are typically distilled from production prompts and real user conversations, which is exactly the data you should not paste into a tool that phones home.