Chat Template Viewer — ChatML, Llama 3, Mistral & Gemma Prompts
Render a messages array into the exact prompt format a model expects — ChatML, Llama 3, Mistral [INST], or Gemma — with all the special tokens. See what apply_chat_template actually produces. 100% local.
Last updated:
CommentsEnter a messages array and this viewer renders the exact prompt string a model expects — ChatML, Llama 3, Mistral [INST], or Gemma — including every special token like <|im_start|>, <|eot_id|>, or [INST]. It's what a tokenizer's apply_chat_template() produces, shown literally so you can see turn boundaries and role headers. Everything runs in your browser.
Used by GPT-3.5/4-era models and Qwen. Roles wrapped in <|im_start|>…<|im_end|>.
<|im_start|>system You are a helpful assistant.<|im_end|> <|im_start|>user What is the capital of France?<|im_end|> <|im_start|>assistant The capital of France is Paris.<|im_end|> <|im_start|>user And of Japan?<|im_end|> <|im_start|>assistant
Rendering runs in your browser. Special tokens are shown literally so you can see the exact prompt the model’s tokenizer builds.
What is Chat Template Viewer?
Open-weight chat models aren't trained on raw role/content JSON — they're trained on a single prompt string in which each turn is wrapped in model-specific control tokens. The template that does the wrapping is part of the tokenizer (Hugging Face exposes it as apply_chat_template), and getting it wrong is a common reason a local model ignores the system prompt or rambles: the markers it learned to key off are missing. This viewer renders your messages into four of the most common formats so you can see and copy the real prompt. ChatML (OpenAI / Qwen) uses <|im_start|>role … <|im_end|>. Llama 3 uses <|start_header_id|>role<|end_header_id|> with <|eot_id|> terminators after a leading <|begin_of_text|>. Mistral wraps instructions in [INST] … [/INST] and folds the system prompt into the first user turn because it has no system marker. Gemma uses <start_of_turn> … <end_of_turn>, calls the assistant 'model', and likewise has no system role. Each render ends with an open assistant/model turn so the model knows to continue.
How to render a chat template
- 1Pick the target model family (ChatML, Llama 3, Mistral, or Gemma).
- 2Edit the system/user/assistant messages, adding or removing turns.
- 3Copy the rendered prompt — the special tokens are shown exactly as the model sees them.
Key Concepts
- apply_chat_template
- The tokenizer method that flattens messages into the trained prompt format.
- Special tokens
- Control markers like <|im_end|> and <|eot_id|> that delimit turns and roles.
- MCP & agent files
- Related: generate config and instruction files for AI tools.
Tips & Best Practices
- ▸Mistral and Gemma have no system role — the system prompt is prepended to the first user turn.
- ▸Always match the template to the exact model variant; a mismatched template silently degrades instruction-following.
Frequently Asked Questions
What is a chat template?
A chat template defines how a list of role/content messages is flattened into a single prompt string with the special control tokens a model was trained on. Hugging Face tokenizers expose it as apply_chat_template(). Using the wrong template — or none — degrades a model's instruction-following because the markers it learned (turn boundaries, role headers) are missing.
What is the ChatML format?
ChatML wraps each turn as <|im_start|>role\ncontent<|im_end|>, ending with an open <|im_start|>assistant so the model continues. It's used by OpenAI's GPT-3.5/4-era models and by Qwen. It's one of the simplest and most readable chat formats.
How is the Llama 3 template different from Mistral?
Llama 3 uses <|start_header_id|>role<|end_header_id|> headers and <|eot_id|> to end each turn, beginning with <|begin_of_text|>. Mistral uses [INST]…[/INST] blocks around user instructions and folds the system prompt into the first user turn — it has no dedicated system role marker.
Does Gemma support a system prompt?
Gemma's template has no system role. The convention is to prepend system instructions to the first user turn. Gemma also uses <start_of_turn>…<end_of_turn> and labels the assistant as 'model' rather than 'assistant'.
Try Next
Text Chunker
Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.
Related Tools
Prompt Template Tester
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Prompt Diff
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.
Embedding Cost Calculator
Estimate the cost of embedding a corpus — pick a model, enter the number of documents and average tokens each, and get the total token count and dollar cost. 100% local.
Vector Storage Calculator
Estimate how much memory or disk your embeddings need — enter vector count, dimensions, and precision (float32/float16/int8/binary) to see raw and indexed size. 100% local.
Prompt Cache Calculator
See how much prompt caching saves you. Enter your cached prefix size, per-request tokens, volume, and hit rate to compare cost with and without caching across models that support it. 100% local.
Batch API Cost Calculator
Compare real-time vs Batch API cost for a bulk job. Enter request count and per-request tokens to see how much the ~50% batch discount saves across models that support it. 100% local.