Python t-String Renderer Playground
Type a template, fill in the values, pick a renderer. See the final output and how the Template splits into strings and interpolations. No Python 3.14 install needed.
How the playground works
- You type a template. The tool scans it for
{placeholder}markers, the same syntax a real Python t-string uses. - It splits the template into parts. Static text becomes the
stringstuple and each marker becomes an interpolation, exactly how a PythonTemplateobject is structured. - A value input appears for every placeholder. Whatever you enter is treated as the evaluated value of that interpolation.
- You pick a renderer. Each renderer walks the template parts and assembles output its own way: HTML escaping, SQL parameterization, JSON log structuring, LLM message building, or a raw dump.
- You see two panels. The Template breakdown shows the raw
stringsandinterpolations; the output panel shows the rendered result with a copy button.
What each renderer produces
The five renderers mirror the patterns from the companion blog post. Switch between them to see how the same template produces very different output.
Dumps the strings tuple and the interpolations list so you can see precisely how your template was parsed before any renderer touches it.
Escapes every interpolated value with HTML entity encoding while leaving your static markup untouched. Type <script> into a value to watch it become <script>.
Replaces each value with a $1-style placeholder and collects the values into a separate params list. Lists expand into IN clauses and None becomes NULL, so injection is structurally impossible.
Builds a JSON log entry with the assembled message plus one field per interpolation, keyed by the placeholder name, so log aggregators can query individual fields.
Assembles a role/content message dict and scans each value for prompt-injection phrases, replacing flagged content with a safe placeholder before it reaches the model.
Template syntax reference
The playground accepts the placeholder syntax you would use in a real Python t-string, plus two value conventions for the SQL renderer.
| You type | Meaning |
|---|---|
| {name} | An interpolation named "name". A value input appears for it. |
| Hello {name}! | Static text plus one interpolation. "Hello " and "!" become the strings tuple. |
| {a} {b} {a} | Repeated placeholders share one value input; both positions use it. |
| [active, pending] | SQL renderer only: a value that expands into an IN clause ($n, $n+1). |
| None | SQL renderer only: renders a bare NULL instead of a placeholder. |
When to use this tool
Match your goal to a renderer and a sample template.
| Your goal | Renderer |
|---|---|
| See how a template is parsed | Raw Template |
| Confirm user input gets escaped | HTML |
| Check IN-clause parameterization | SQL |
| Preview a structured log line | Structured Log |
| Watch injection protection trigger | LLM Prompt |
Frequently Asked Questions
What does the t-string playground do?
It lets you experiment with Python 3.14 t-strings without installing Python. You type a template with {placeholder} markers, fill in the values, and pick a renderer. The tool shows both the assembled output and the Template breakdown, so you can see exactly how the strings and interpolations map onto what each renderer produces.
Is this running real Python 3.14 in my browser?
No. The tool is a JavaScript approximation of Python's Template model. It splits your template on {...} markers into static strings and interpolation expressions, then runs each renderer's logic (HTML escaping, SQL parameterization, JSON log structuring, LLM message building) in the browser. The behavior mirrors the real renderers from the companion blog post, but no Python runtime is involved.
How is this different from a normal Python playground?
| This playground | Generic Python REPL | |
|---|---|---|
| Python 3.14 required | No, runs in the browser | Yes, Pyodide does not ship 3.14 yet |
| t-string renderers | 5 built in, ready to test | You write them yourself first |
| Template breakdown | Shown for every template | Manual inspection in the REPL |
| Setup | None | Install or load a runtime |
Does the tool send my template or values anywhere?
No. Everything runs client-side in your browser. Nothing you type is saved, logged, or sent to a server. The page is a static file served from Cloudflare's edge with no backend.
How do I test a SQL IN clause with a list of values?
Pick the SQL renderer, then wrap the value in brackets. For a {status_list} placeholder, type the value below:
[active, pending]The renderer expands it into ($2, $3) and appends both items to the params list, exactly like the production query() renderer. Type None for any value to render a SQL NULL instead of a placeholder.
Why did the LLM Prompt renderer flag my message?
The prompt renderer checks each interpolated value against a list of known prompt-injection phrases such as "ignore previous instructions". When one matches, it replaces the message content with a safe placeholder instead of passing the user text through. This demonstrates how a t-string renderer can inspect values before assembling the final prompt, which an f-string cannot do.