HTML to Backend Language Output Code
WebEverything runs locally in your browser — nothing is uploaded
Convert a block of HTML into output statements for ASP, VB.NET, JSP, PHP or Perl. The hard part was never the quotes — it is the handful of traps that each hide well: VB doubles a quote while the C family backslashes it, and getting that wrong blanks the page; a dollar sign interpolates inside PHP double quotes, so a price in your markup quietly loses a chunk; and a `%>` inside a JSP string, or a `?>` inside PHP, ends the script block early — the rest of your HTML then shows up as page text, exactly like `</script>` does when you embed markup in JavaScript. All of it is handled here per language, and anything that cannot be expressed is spelled out in a comment in the generated code.
Features
- Five targets: classic ASP (VBScript), ASP.NET (VB.NET), JSP, PHP and Perl
- Quotes escaped the way each language wants: doubled for the VB family, backslashed for PHP, Perl and JSP
- Dollar signs in PHP and Perl, and at signs in Perl, are escaped so they are not interpolated as variables
- A %> in the markup is written as %\>, and a PHP close tag as \x3f>, so a script block cannot end early
- One output statement per line, with line breaks preserved instead of collapsing the markup onto one line
- Line breaks always use \n rather than a platform-dependent println, so Windows and Linux produce the same file
- Accepts CRLF and LF input, and always outputs LF
- Blank lines and the final line break are handled faithfully — no extra statement, none missing
- Comments come out in English, because they are going into a .jsp or .php file
- The output is syntax-highlighted and can be copied in one go
How to use
- Paste the HTML you want to print
- Pick the target language
- Turn off script-close escaping only if you are certain the markup contains no close tag
- Copy the statements into your template file
FAQ
- Why one statement per line instead of one big string?
- Because that is the form you can paste into a template and debug line by line. A single string is shorter, but it needs each language own multi-line mechanism — a heredoc in PHP and Perl, concatenation in VB — which is five different spellings, and when one escape goes wrong you have to find the bad line inside a wall of text. With one statement per line, the broken line is the line.
- Why does every line end with & vbLf or a \n?
- Because none of these output statements adds a line break on its own: Response.Write, echo and out.print all write exactly the string you give them. Without the break the whole block collapses onto one line — harmless for most tags, but inside a `<pre>` or a `<textarea>` those newlines are the content, so dropping them corrupts it. If the last line of your input has no trailing newline, none is added here either.
- Why are dollar signs escaped in PHP and Perl?
- Because double-quoted strings interpolate there: PHP expands `"$name"`, and Perl expands both `$name` and `@name`. Markup containing a placeholder or a price (`<b>$99</b>`, `mailto:me@example.com`) would lose a chunk of content, or raise a warning about an undeclared variable at runtime — and both failures look like the data was simply empty. In JSP a dollar sign means nothing special, so it is left alone.
- What does the script-close escaping option do?
- JSP and ASP code lives inside `<% ... %>`, PHP inside `<?php ... ?>`, and the template parser scans the source for those two characters without caring whether they sit inside a string. A line like `echo "<div>?>";` therefore leaves PHP mode right there, and everything after it is printed to the page as text — no error, no blank page, just odd text in the browser. With the option on, `%>` is written as `%\>` (the escape these parsers understand) and a PHP close tag as `\x3f>` — the value is unchanged and the sequence no longer appears in the source.
- Why does the generated PHP have no closing tag?
- The PHP manual recommends omitting the closing `?>` in a file that is entirely PHP: any newline or space after it is sent to the browser, which leaves stray whitespace at the start of the response — and that whitespace is a well-known cause of "headers already sent". The `%>` in ASP and JSP is required, so it stays.
- Is my HTML uploaded?
- No. The conversion happens entirely in browser memory; the page makes no requests and works offline.
Related tools
HTML ↔ JS
WebEscape HTML into a JS string literal — quotes, newlines and a broken `</script>` — or unescape one back into readable HTML. Runs in your browser.
Redirect Code
WebGenerate redirect code for Apache, Nginx, PHP, ASP, JSP, Java and more, with the 301, 302, 307 or 308 status you choose. Runs entirely in your browser.
HTML Entities
EncodingTurn < > & and quotes into HTML entities and decode them back in a single pass, so &lt; becomes <, not an angle bracket. Runs in your browser.
HTML Formatter
FormatFormat HTML online by tag level, keeping text and inline tags on one line and script or pre content untouched. Runs locally, with nothing uploaded.
URL Parser
WebParse a URL into scheme, host, port, path, query parameters and fragment, with each parameter shown raw and decoded. Runs entirely in your browser.
User-Agent Parser
WebParse a user agent into browser, version, OS, device type and engine, and see which rules matched. Pattern matching only. Runs entirely in your browser.