DevTools Logo

CSV to Finetune JSONL Converter

CSV to Finetune JSONL Converter

Map CSV columns to system/user/assistant chat messages and emit OpenAI-format JSONL for fine-tuning. Nothing leaves your browser.

Runs in your browser
Try an example

CSV input

Fine-tuning JSONL

Can't convert

Paste CSV or upload a file to build fine-tuning examples

One CSV row becomes one JSON object with a messages array. Results update as you type.

Details

Paste or upload a CSV, assign each column a system, user, assistant, or ignore role, and every row becomes one JSON object with a messages array — the chat format OpenAI fine-tuning expects. Columns named like prompt_1, reply_1, prompt_2, reply_2 group into ordered multi-turn conversations. Each example is validated against the chat schema before export: the first message must be system or user and the last message must be an assistant reply, so rows that would be rejected by the training API are listed with their row numbers instead of silently exported. Token estimates use a CJK-aware heuristic that includes the ~4-token-per-message and 3-token-per-example overhead the API counts, and the stats bar projects training cost as tokens × epochs × rate. Everything runs locally in your browser: your dataset is never uploaded.

More examples

Single-turn Q&A dataset

question,answer
"How do I reset my password?","Go to Settings and click Reset password."
"What are your hours?","We are open 9 to 5."

Two rows become two JSONL examples, each {"messages":[{role:"user",…},{role:"assistant",…}]}.

Multi-turn conversation

prompt_1,reply_1,prompt_2,reply_2
"What is a p-value?","How surprising your data is if no effect exists.","One sentence, please.","It measures surprise under the null hypothesis."

Numbered columns are ordered by their suffix and interleaved user/assistant into a four-message conversation.

Fixed system prompt

System message (fixed text): You are a concise tax assistant.

A literal typed into the mapping panel is prepended as the system message of every example.

    Examples

    Support tickets to single-turn JSONL

    Input
    question,answer
    "How do I reset my password?","Settings, then Security, then Reset password."
    Output
    {"messages":[{"role":"user","content":"How do I reset my password?"},{"role":"assistant","content":"Settings, then Security, then Reset password."}]}

    One row, one example: the question becomes the user turn, the answer the assistant turn.

    Two turns from numbered columns

    Input
    prompt_1,reply_1,prompt_2,reply_2
    "Define p-value.","Surprise under the null.","Shorter.","It measures surprise if no effect exists."
    Output
    messages: user → assistant → user → assistant, in suffix order

    The suffix number, not the column position, decides turn order, so prompt_2 can sit anywhere in the file.

    Row with a missing answer

    Input
    question,answer
    "Orphan question",
    Output
    Skipped rows: row 1 — last message is not assistant

    The row is listed in the skip panel and excluded from the export until you opt in explicitly.

    About this tool

    The CSV to Finetune JSONL Converter turns a plain spreadsheet into a training file for OpenAI-style chat fine-tuning. The fine-tuning API does not accept rows of raw text: every training example must be a JSON object whose messages array alternates system, user, and assistant turns, ends with an assistant reply, and stays inside the model's per-example token budget. Hand-rolling that with a Python script is easy to get subtly wrong — a missing assistant turn, an example that starts with the assistant, or content that silently breaks the token budget — and the API only tells you after the upload fails. This tool enforces those rules while you are still editing the CSV.

    You assign each column a role: system, user, assistant, or ignore. A column named question becomes the user turn and answer becomes the assistant turn; common names (prompt, instruction, response, completion, reply, and so on) are guessed automatically, and sample cell values are shown next to every column so cryptic headers are easy to map. Numbered columns such as prompt_1, reply_1, prompt_2, reply_2 are ordered by their suffix and interleaved into multi-turn conversations, and a fixed system text typed into the mapping panel is prepended to every example. A constant system column works the same way for per-row system prompts.

    Validation happens per example, not per file. Rows whose last message is not an assistant reply, whose mapped cells are all empty, or that start with the assistant role are listed with their CSV row numbers and excluded from the export until you explicitly turn on "Include rows failing validation" — nothing is silently dropped and nothing invalid is silently exported. Token estimates use a CJK-aware heuristic that includes the roughly 4 tokens of overhead per message and 3 priming tokens per example that the API counts, warns when examples pass 4,096 or 16,384 estimated tokens, and feeds a cost estimate of tokens × epochs × your price per million tokens.

    Everything runs in your browser: the CSV is parsed with RFC 4180 rules (quoted fields, doubled quotes, embedded newlines, BOM stripping, comma/semicolon/tab/pipe delimiter detection), and the .jsonl you download never touches a server. If you already have a JSONL file and need to check it, the Fine-tune JSONL Validator validates that direction; this tool is the generation step before it.

    What this tool does not do

    • Conversion happens in memory, so inputs are capped at about 5 million characters; split very large exports into chunks and convert them separately.
    • Token counts are heuristic estimates, not exact BPE counts, and no encoding/model selector changes them — treat them as budgeting numbers.
    • Only chat-format (messages) output is produced; the legacy prompt/completion fine-tuning format is not emitted.

    How to use this tool

    1. Load the CSV

      Paste CSV text, upload a .csv/.tsv file, or try an example. The delimiter (comma, semicolon, tab, pipe) is auto-detected, and a header-less file works too — just switch off "First row is header".

    2. Map columns to roles

      In the mapping table, assign each column system, user, assistant, or ignore. Numbered columns group into ordered turns in multi-turn mode; a fixed system text or a system column is prepended to every example.

    3. Review skipped rows

      Rows that fail validation — usually a missing assistant reply — are listed with their row numbers. Fix them in the source or turn on "Include rows failing validation" to export them anyway.

    4. Download the JSONL

      Copy the sample line or download finetune.jsonl. The stats bar shows rows in, examples out, skipped rows, approximate tokens, and the estimated training cost at your epochs and $/1M rate.

    Use cases

    Turning support tickets into a fine-tuning set

    Export a ticket CSV with question and answer columns, map them to user and assistant, and download a ready-to-upload JSONL with invalid rows already flagged.

    Converting labeled prompt/completion exports

    Older prompt/completion datasets reshape cleanly: the prompt column becomes the user turn and the completion column the assistant turn of the chat format.

    Building multi-turn conversation data

    Numbered prompt/reply column pairs become ordered two-, three-, or N-turn conversations, with turn gaps flagged before they reach the API.

    Budgeting a training run

    Approximate token totals with the documented per-message overhead, times epochs and your $/1M rate, give a realistic cost before you commit to training.

    What the output looks like

    FieldRule
    Line structureOne JSON object per line (JSONL) — each line parses independently
    messagesRequired array of {role, content} objects; roles are system, user, assistant
    First messagesystem or user — an example that starts with assistant is rejected
    Last messageassistant with non-empty content — this is what the model learns to produce
    metadata (optional)Off-schema {row_index} marker for traceability; strict endpoints may reject it
    EncodingUTF-8, no BOM; newlines inside cells are escaped by JSON.stringify

    Token estimates include ~4 tokens per message plus ~3 priming tokens per example, matching OpenAI's documented chat-format counting; CJK text is estimated at roughly one token per character.

    Common mistakes

    Mistake:Assuming every row will convert.

    Fix:Rows with an empty assistant cell or an assistant-first mapping fail the schema. The skip panel lists each failing row number; repair them in the source or opt in to exporting them, but know they will be rejected by the training API.

    Mistake:Trusting the token estimate as exact.

    Fix:Counts use a CJK-aware chars-per-token heuristic, not the model's real tokenizer. They include the documented overhead and are close enough for budgeting, but use the provider's counting API for billing-grade numbers.

    Mistake:Enabling the metadata field for strict endpoints.

    Fix:The documented chat fine-tuning schema has only messages at the top level. The optional metadata row-index marker is convenient for tracing, but Azure and other strict endpoints may reject files that carry it.

    Mistake:Letting ordinary numbered columns fake a turn pattern.

    Fix:Multi-turn grouping orders columns by numeric suffixes, and a gap warning appears when suffixes skip (for example _1 then _3). Columns like address_1 that merely end in a number should be assigned Ignore.

    Frequently asked questions

    What JSONL format does OpenAI fine-tuning expect?

    One JSON object per line, each with a messages array in the chat format: objects with a role (system, user, or assistant) and a content string. The first message must be system or user, and the last message must come from the assistant, because that final turn is what the model is trained to produce. This converter emits exactly that shape, one line per CSV row, and validates every example against those rules before you download.

    Why must each example end with an assistant message?

    The fine-tuning objective is to predict the assistant's reply given everything before it. If a training example does not end with an assistant message, there is nothing to learn toward, and the API rejects the file. Rows whose final turn is missing — a support-ticket CSV with an empty answer cell is the classic case — are listed in the skip panel with their row numbers and excluded from the export until you explicitly turn on "Include rows failing validation".

    How many tokens can one training example have?

    Models cap examples well above 4,096 tokens and modern chat models around 16,384 or more; examples beyond the limit are rejected or truncated. The tool estimates each example's tokens including the roughly 4 tokens of overhead per message and 3 priming tokens per example that the API counts, and warns when examples pass the 4,096 soft limit or 16,384. Estimates use a CJK-aware heuristic rather than the model's exact tokenizer, so treat them as budgeting numbers, not billing numbers.

    Can one CSV row become a multi-turn conversation?

    Yes. Switch to multi-turn mode and use numbered column pairs such as prompt_1, reply_1, prompt_2, reply_2. Columns are ordered by their numeric suffix (not their position in the file) and interleaved user/assistant, so a row becomes a full conversation. If the suffixes skip — prompt_1 then prompt_3 — the tool warns once so an accidental name like address_1 doesn't silently reshape your data.

    Is my CSV uploaded anywhere?

    No. Parsing, mapping, validation, token estimation, and the .jsonl download all happen in your browser; the file never leaves your device and nothing is logged. You can load the page, disconnect from the network, and a dataset already pasted still converts.

    How is the training cost estimate calculated?

    Cost = approximate total tokens × epochs × your price per million tokens. The epochs field defaults to 3 because fine-tuning typically makes multiple passes over the dataset, and each pass costs tokens again. Enter your training price in the $/1M field (leave it empty to hide the cost row). Real billed usage can differ slightly because the estimates are heuristic.

    References & standards