---
title: Using external templating libraries (Jinja, Liquid, etc.) with Langfuse prompts
seoTitle: "External Templating Libraries in Prompts"
description: Learn how to use Jinja2, Liquid, or other templating libraries with Langfuse prompts for advanced templating features like conditionals, loops, and filters.
tags: [prompt-management]
---

# Can I use Jinja, Liquid, or other templating libraries with Langfuse prompts?

Yes! While Langfuse has its own [variable syntax](/docs/prompt-management/features/variables) (`{{variable}}`) with the `compile()` method, you can use external templating libraries like Jinja2 or Liquid instead for advanced features like conditionals, loops, and filters.

**Do you need external templating libraries?** Managing external templating languages in a prompt editor can be cumbersome. You might be able to do this in a simpler way using [Langfuse variables](/faq/all/conditional-prompt-embedding) instead.

## How it works

Langfuse prompts return plain strings (text prompts) or arrays of message objects (chat prompts). If you want to use an external templating library, store your Jinja2/Liquid template as-is in Langfuse and apply your templating library client-side:

1. Store your Jinja2/Liquid template in Langfuse (don't use Langfuse's `{{variable}}` syntax)
2. Fetch the prompt from Langfuse using `get_prompt()`
3. Access the raw prompt string via `prompt.prompt`
4. Apply your templating library (Jinja2, Liquid, etc.) to render the final prompt
5. Pass the result to your LLM

## Limitations

When using external templating libraries instead of Langfuse's native variable syntax:

- **Playground:** The Langfuse [Playground](/docs/prompt-management/features/playground) only supports automatic rendering with Langfuse's native variable syntax. Prompts with Jinja2/Liquid syntax won't be automatically testable directly from Prompt Management. However, you can still jump from traces (which contain the compiled prompt) to the Playground.
- **Prompt experiments:** You cannot use in-UI prompt experiments since they rely on Langfuse's `compile()`. You can use [Experiments via the SDK](/docs/evaluation/experiments/experiments-via-sdk) where you compile the prompt yourself as part of the task.
- **Variable detection:** Langfuse's UI will only detect variables using the `{{variable}}` syntax. Jinja2/Liquid variables won't appear in the variable list.

## Related resources

- [Langfuse Variables](/docs/prompt-management/features/variables)
- [Message Placeholders](/docs/prompt-management/features/message-placeholders)
- [Prompt Composability](/docs/prompt-management/features/composability)
- [Dynamically selecting sub-prompts at runtime](/faq/all/conditional-prompt-embedding)

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/faq/all/using-external-templating-libraries.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx langfuse-cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
