Skip to content
UniKit

HTML to PHP template

Turn `{{var}}` and `data-bind="text: var"` markers into PHP echo statements, escaped with htmlspecialchars by default or emitted as a bare `<?php echo $var; ?>` when unchecked. Only expression output is converted: control flow such as loops, conditions and includes is out of scope, and existing `<?php foreach (...): ?>` blocks stay as they are.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

HTML template

Result

The result can be copied directly.

Paste HTML to see the PHP template

Characters: 0 · Lines: 0 · Interpolations: 0 · data-bind bindings: 0

What this tool does

  • Turn a static HTML mock-up into a server template without retyping variables.
  • Audit which `{{variables}}` get escaped and which are emitted raw.
  • Make data-bind relationships explicit in the target template syntax.

Example

Input

<h1>{{title}}</h1>
<p data-bind="text: price">0</p>

Output

<h1><?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></h1>
<p data-bind-source="price"><?php echo htmlspecialchars($price, ENT_QUOTES, 'UTF-8'); ?>0</p>

`{{title}}` becomes `<?php echo htmlspecialchars($title, …); ?>`; the data-bind attribute is dropped and the echo inserted.

Frequently asked questions

Is control flow converted too?

No. Only expression output is rewritten; loops and conditions already written in the template are kept as-is and never generated for you.

What about `{{a + b}}`?

It is not a valid identifier path (letters, digits, dots, indexes), so it is left in the output and not recorded in statements.

What does the escape switch do?

On emits an escaped form such as `<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>`, off emits `<?php echo $title; ?>`; both only touch echo positions.

Does it validate template syntax?

No. The output is a text rewrite; correctness has to be verified in the target runtime or template engine.

Keywords:html2phpphp templatedeveloper

Related tools