~/tools / Model files and chat templates / Ollama Template Tester

Ollama Template Tester — Run an Ollama TEMPLATE and see the exact prompt

Paste the TEMPLATE of an Ollama model (from ollama show --template or your Modelfile), add a conversation, tools or a prompt, and see the exact text Ollama hands to the model: special tokens, line breaks and all. The tool runs the template the way Ollama does, with Go's template rules, Ollama's data (messages, tool calls, tools, think) and its three ways of running a template. It also tells you whether Ollama will use your TEMPLATE at all or the chat template inside the GGUF file, and when Ollama will refuse a request for tools or thinking. Nothing leaves your browser.

Examples

ollama show --template <model> prints the template of a model you have. The text between the triple quotes after TEMPLATE in a Modelfile works too.

Request

The same shape as /api/chat: role, content, and optionally thinking, tool_calls, tool_name and images.

The same shape as tools in /api/chat. Leave it empty for no tools.

Advanced: the model's SYSTEM and its GGUF chat template

The SYSTEM line of the Modelfile. Ollama adds it when the first message is not a system message (in /api/generate, when system is empty).

Paste it to see whether Ollama uses TEMPLATE or this one. GGUF Metadata Viewer shows it.

What the model receives

<|im_start|>system
You are a helpful assistant.

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"type": "function", "function": {get_weather Get the current weather for a city {object <nil> <nil> [city] {"city":{"type":"string","description":"City name"}}}}}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call><|im_end|>
<|im_start|>user
What is the weather in Tokyo?<|im_end|>
<|im_start|>assistant
<tool_call>
{"name": "get_weather", "arguments": {"city":"Tokyo"}}
</tool_call><|im_end|>
<|im_start|>user
<tool_response>
{"temperature": 20}
</tool_response><|im_end|>
<|im_start|>assistant
It is 20°C in Tokyo.<|im_end|>
<|im_start|>user
Thanks!<|im_end|>
<|im_start|>assistant
954 characters, 955 bytes

About this template

How Ollama ran it
Once, with the whole conversation in .Messages
Names it uses
$, $i, $last, arguments, content, function, messages, name, prompt, response, role, system, toolcalls, tools
What it supports (for Ollama)
tools

Check with your own Ollama

Replace MODEL with the name of your model. _debug_render_only is a debug option in Ollama's source, not in the API documentation, so it may change. The answer has the prompt in _debug_info.rendered_template.

curl -s http://localhost:11434/api/chat -d '{"model":"MODEL","messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"What is the weather in Tokyo?"},{"role":"assistant","content":"","tool_calls":[{"function":{"name":"get_weather","arguments":{"city":"Tokyo"}}}]},{"role":"tool","content":"{\"temperature\": 20}","tool_name":"get_weather"},{"role":"assistant","content":"It is 20°C in Tokyo."},{"role":"user","content":"Thanks!"}],"tools":[{"type":"function","function":{"name":"get_weather","description":"Get the current weather for a city","parameters":{"type":"object","properties":{"city":{"type":"string","description":"City name"}},"required":["city"]}}}],"stream":false,"_debug_render_only":true}'

Models with a RENDERER or PARSER line in the Modelfile, and gpt-oss, use renderers built into Ollama, not TEMPLATE.

When the conversation is longer than the context (num_ctx), Ollama drops the oldest messages but keeps the system messages and the last message. This tool does not count tokens, so it always shows the whole conversation.

For qwen3 models and deepseek-r1, Ollama removes <think>…</think> from assistant messages before the last user message. This tool does not.

Printing a whole message or {{ .Messages }} shows memory addresses in Ollama (0xc…), which change every time. The tool shows a placeholder.

currentDate and yesterdayDate use today's date on your computer. Ollama uses the date on the server.

Checked on 2026-11-09 against Ollama's source (v0.40.15), Go's text/template and Ollama 0.40.11: Ollama: Template · template.go

Everything runs in your browser. Nothing is sent anywhere.

Ollama turns a conversation into the text a model reads with the TEMPLATE of the model, written in Go's template language: {{ range .Messages }}, {{ .Role }}, {{ .Content }}, {{ if .Tools }} and so on. A small mistake, such as a missing line break, a {{- that trims too much or a field name that does not exist, changes what the model sees or makes every request fail. This tool runs your template the way Ollama does. It follows Go's text/template rules (trim markers, variables, range, with, comparisons, printf, the error messages), passes the same data Ollama passes (System, Messages with Role, Content, Thinking, ToolCalls, ToolName and ToolCallID, Tools, Think, ThinkLevel, IsThinkSet, Prompt, Suffix, Response) and has Ollama's extra functions (json, currentDate, yesterdayDate, toTypeScriptType). It also copies how Ollama prepares the data: system messages are joined into .System, consecutive messages from the same role are joined with a blank line, the model's SYSTEM is added when the first message is not a system message, and images become [img-0], [img-1] and so on. A template that never uses .Messages runs the older way, once per turn with .Prompt and .Response, and Ollama adds {{ .Response }} to a template that uses neither. Since Ollama 0.40, a model can also carry a chat template inside its GGUF file (tokenizer.chat_template), and Ollama picks one of the two by what each can do: tools, thinking and fill-in-the-middle. Paste the GGUF chat template under Advanced and the tool tells you which one Ollama will use. We checked the tool in three ways: against Go's own text/template (Go 1.26.6) running Ollama's template code on 243 cases, including Ollama's 20 built-in templates, whose test outputs it matches; against Ollama 0.40.11 on this computer with 330 /api/generate requests; and with 49 /api/chat requests to qwen2.5:7b and to models we made with our own TEMPLATEs. The output and the error messages matched.

The core logic of this tool is open source under the MIT License. github.com/seigo5555/toolkitbox-lib/src/ollama-template.ts

Use Cases

  • Check a TEMPLATE you are writing for a Modelfile before you run ollama create: line breaks, special tokens, the system message, tool calls and tool results
  • Find out why changing TEMPLATE has no effect, and whether Ollama uses it or the chat template in the GGUF file
  • See exactly what a model receives in a long conversation with tools, to debug wrong or missing tool calls

Usage

  1. Paste a template into the box (ollama show --template <model> prints the template of a model you have), or start from one of the examples.
  2. Choose /api/chat and edit the messages and tools as JSON, the same shape as the API, or choose /api/generate and fill in the prompt, system and suffix. Set think if you use it.
  3. Read the result, with whitespace shown if you need it. To compare with your own Ollama, run the curl command at the bottom with your model's name.

FAQ

I changed TEMPLATE, but the output did not change. Why?

Since Ollama 0.40, a model can have two templates: TEMPLATE from the Modelfile and the chat template inside the GGUF file. Ollama picks the one that can do more (tools, thinking, fill-in-the-middle). In our test with Ollama 0.40.11, a TEMPLATE without tools was ignored in a model made from qwen2.5:7b, because the GGUF chat template of qwen2.5:7b supports tools. The server log shows the choice in the "template selection" line (selected=go_template or selected=gguf_chat_template), and setting OLLAMA_GO_TEMPLATE=1 for the server makes Ollama use TEMPLATE whenever a model has one.

How can I see the prompt my Ollama really builds?

Ollama's source has a debug option, _debug_render_only, that returns the prompt instead of running the model (as _debug_info.rendered_template). We used it to check this tool. It is not in the API documentation, so it may change. The tool builds the curl command for you.

What is the difference between templates with .Messages and with .Prompt?

If the template uses .Messages, Ollama runs it once with the whole conversation. If it does not, Ollama runs it once per turn with .System, .Prompt and .Response, and for the last turn it cuts the template off after {{ .Response }}, so the model continues from there. The tool shows which way was used.

Why does Ollama answer "does not support tools" or "does not support thinking"?

Ollama refuses a request with tools when the template it uses does not support tools (a TEMPLATE supports them when it uses .Tools), and a request with think set to true or a level when the template has no thinking part. For a template that does have thinking, Ollama turns think on when the request does not set it. The tool shows both.

The tools in my prompt do not look like JSON. Is that a bug in the tool?

Probably not. In Go's templates, a value prints as JSON only when its type says so. Ollama's .Tools, a whole tool and .Function.Arguments print as JSON, but .Function prints in Go's own format. In our test, the template of qwen2.5:7b uses {{ .Function }}, and Ollama 0.40.11 sent the model text such as {get_weather Get the weather {object <nil> <nil> [city] {…}}}. Use {{ json .Function }} if you want JSON.

Is my template sent anywhere?

No. Everything runs in your browser.

Related