LangChain Prompt Template Builder
Visually build a LangChain ChatPromptTemplate with System/Human/AI messages, variable placeholders and few-shot examples, and generate copy-ready Python or JavaScript code.
FreeOnline Tool
Loading…
How to Use
- Enter a template name, e.g. code_review_assistant.
- Add message templates with the + System, + Human, + AI, + Function and + Tool buttons and edit each message content.
- Use {variable_name} placeholders in message content; variables referenced by templates are automatically marked as 'referenced' in the variable list, and you can also add variables manually.
- (Optional) Click '+ Add example conversation' to attach few-shot examples as Human/AI pairs.
- Switch between the Python and JavaScript/TypeScript output tabs and click 'Copy' to copy the generated code.
- Paste the code into your project and call format_messages (Python) or formatMessages (JS) with your variables as shown in the comments.
Features
- Visual editing for System, Human, AI, Function and Tool message templates.
- Auto-detects {variable_name} placeholders in message content and lists them, with manual add and remove support.
- Supports multiple few-shot example pairs (Human/AI) that are merged into the generated code.
- Generates Python code (langchain_core ChatPromptTemplate) or JavaScript/TypeScript code (@langchain/core) with syntax highlighting.
- Generated code includes call examples (format_messages / formatMessages) as comments, ready to copy and use.
Use Cases
Build a code review prompt
Define a senior reviewer system prompt and a Human message with {code} and {language} placeholders to build a reusable review template.
Customer support Q&A template
Set the assistant personality in a System message, use an {input} placeholder in Human, and add few-shot examples to improve answer quality.
Templates with Function messages
Add a Function message when the assistant must call tools or return structured JSON, and fill in your placeholders.
Multi-turn conversation templates
Stack System, Human and AI messages in order to build a multi-turn template with history examples, then paste it into your LangChain project.
FAQ
Can the generated code run as-is?
Almost. Install the dependencies first: langchain-core for Python, or @langchain/core for JS. Then pass the variables as shown in the call comments.
How are variables detected?
Any {variable_name} in message content is auto-detected and added to the variable list with a 'referenced' badge. Manually added variables also appear in the generated call comments.
What placeholders do Function and Tool messages use?
Function messages are generated with name=function_name and Tool messages with tool_call_id=call_xxx; replace these placeholders with your real values.
Which message types are supported?
System, Human, AI, Function and Tool, covering the common ChatPromptTemplate message types in both Python and JS outputs.
What are few-shot examples for?
Few-shot examples are appended to the template as Human/AI message pairs so the model can follow the demonstrated pattern, which typically improves output quality on specific tasks.