Skip to content

ChatML Formatter

Convert a conversation into ChatML, Llama 3, Mistral, Gemma or Alpaca prompt templates.

Quick Tool Overview

The ChatML Formatter converts a conversation between a JSON messages array, a labelled transcript and the prompt templates local models are trained on — ChatML, Llama 3, Mistral, Gemma and Alpaca — with an optional generation prompt.

What it does
Converts chats into model prompt templates
You give it
Messages as JSON, a template string or a transcript
You get back
The exact prompt string for your model
Best for
Raw completion endpoints, llama.cpp and training data
AI Tools Free, unlimited use No sign-up Runs in your browser

About the ChatML Formatter

Chat models are trained on conversations wrapped in special tokens — ChatML uses im_start and im_end, Llama 3 uses header and end-of-turn tokens, Mistral wraps user turns in [INST] tags. Chat endpoints apply the template for you, but a raw completion endpoint, a llama.cpp server or a training script needs the exact string, and a wrong template quietly makes a good model perform badly.

Paste a conversation as a JSON messages array, an already-formatted ChatML or Llama string, or a transcript with User: and Assistant: labels, and convert it to ChatML, Llama 3, Mistral, Gemma, an Alpaca instruction block, a plain transcript or back to JSON. The generation prompt — the opened assistant turn that makes the model answer rather than continue your message — can be added or left off for training data.

Model quirks are handled and explained: Mistral and Gemma have no system role, so the system message is folded into the first user turn, and consecutive turns from the same role, which several templates reject, are flagged.

Key features of the ChatML Formatter

Five chat templates

ChatML, Llama 3, Mistral [INST], Gemma and Alpaca, plus plain text and JSON.

Reads any common input

JSON messages, ShareGPT turns, ChatML, Llama or Gemma strings and labelled transcripts.

Generation prompt toggle

Open an assistant turn for inference, or leave it off for training examples.

Template quirks handled

System messages are folded in for Mistral and Gemma, which have no system role.

Turn order checks

Consecutive turns from the same role, which several templates reject, are flagged.

How to use the ChatML Formatter

  1. 1

    Paste the conversation

    A JSON messages array, a formatted template string, or a labelled transcript.

  2. 2

    Choose the template

    Match the model: ChatML for Qwen and many fine-tunes, Llama 3, Mistral or Gemma.

  3. 3

    Set the generation prompt

    Keep it for inference; turn it off when building training examples.

  4. 4

    Copy the prompt string

    Send it to a raw completion endpoint, or use it in a dataset.

Frequently asked questions

Chat Markup Language: a prompt format that wraps each message between im_start and im_end tokens with the role name. Qwen, Yi, Hermes and many community fine-tunes use it.

Reviews of the ChatML Formatter

What people who use the ChatML Formatter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the ChatML Formatter. It takes half a minute and no account.

Write the first review

More AI tools