Running on your device · 0 bytes uploaded

Chat template renderer

Turn a system/user/assistant transcript into a documented wire format — ChatML, Llama 2, Llama 3, Mistral, Gemma, or Alpaca — with the token count.

Template
  • The <|im_start|> / <|im_end|> markers are real special tokens in the cl100k and o200k vocabularies — count them with those encodings for the closest number.
The ChatML wire format documented in OpenAI's legacy cookbook examples.
Transcript
message 1
message 2
message 3
message 4
Rendered prompt

Build the transcript, then press Render.

No parity claims — sources only
  • Every template here is a documented wire format, and the page names its source. That is the whole claim: what you see is what the format's documentation says, not a promise that a specific served model accepts it verbatim.
  • Served models often wrap your messages in their own server-side template. Sending this rendered text as a plain user message double-wraps it — these formats are for local engines and prompt debugging, not for chat APIs that already template.
  • Token counts use the selected OpenAI encoding. For non-OpenAI formats that is an approximation by construction — their markers are not special tokens in these vocabularies.
  • Formats with no system slot (Mistral, Gemma) fold the system message into the first user turn and report the fold — nothing is dropped silently.
The six formats
  • ChatML: The ChatML wire format documented in OpenAI's legacy cookbook examples.
  • Llama 2: Meta's documented Llama 2 chat format ([INST] … [/INST] with <<sys>>).
  • Llama 3 / 3.1: Meta's documented Llama 3 chat template (<|start_header_id|> … <|eot_id|>).
  • Mistral (v3): Mistral's documented [INST] … [/INST] chat format.
  • Gemma: Google's documented Gemma turn format (<start_of_turn>user / model).
  • Alpaca: Stanford Alpaca's documented prompt format (Instruction / Input / Response).
Nothing in yet

Paste, drop, or type to begin. Everything stays on this device.

nothing renders until you press Render