Syntax highlighting from a real lexer per language, so a URL inside a string is not read as a comment, with 22 languages, 7 themes, and HTML, PNG and copy-as-markup export
Initializing in your browser…
Scan QR codes from an image or your camera, in this tab. Reads every code in a picture, rescues a faded or transparent one and says which step worked, and parses WiFi, vCard, calendar, geo and payment payloads by their published grammars.
Extract a palette whose every colour is one the image actually contains, with the share of the picture each one covers. Median cut, k-means in CIE Lab or plain frequency, each named.
Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL with a real lexer per language, so a comment inside a string is not deleted and a line break the code depends on is kept, with the byte saving measured
A JavaScript line assigns a URL to a variable and has a comment after it. A pattern-based highlighter reads the two slashes of the URL as the start of a comment and greys out the rest of the line.
Snippet
const u = "https://example.com/a"; // real
Result
The URL is coloured as a string and only the trailing // real is a comment.
Every language here is read by a lexer rather than by a chain of patterns, so a comment marker inside a string is string content and a quote inside a comment opens nothing. The tokens are checked to cover every character of your input exactly once, and the page says so. Copy the code, copy the highlighted markup with the colours written into it, or export a standalone HTML file or a PNG.
Paste code in any of 22 languages and get it coloured correctly, then copy it, copy the highlighted markup, or export a standalone HTML file or a PNG image. Every language is read by a lexer rather than by a chain of pattern replacements, which is the difference between a highlighter that mostly works and one that gets a URL inside a string wrong.
A highlighter makes one claim: it knows what every character of your code IS. A regular expression cannot make that claim, because it cannot tell a comment marker that starts a comment from the same two characters sitting inside a string. Put a URL in a JavaScript string with a real comment after it and a pattern-based highlighter colours the URL, the closing quote, the semicolon and the comment as one long comment.
So nothing here works that way. Each language is tokenised: the source is walked once, left to right, and every character comes out inside exactly one token that knows what it is. Six languages are read by lexers this project already had for its minifier and its SQL formatter: JavaScript and TypeScript (which includes deciding whether a slash divides or opens a regular expression, and reading the expressions inside a template literal as code), CSS and SCSS (including the unquoted url() form), HTML and XML (where a greater-than sign inside an attribute value does not end the tag, and a close tag inside a script string is not markup), and SQL, which offers all five dialects because they disagree about what ends a string literal. JSON is read by the same tokenizer the JSON formatter uses and YAML by the yaml package's own lexer. Markdown is read as block structure, so a number sign inside a fenced code block is not a heading. The remaining twelve (Python, Java, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Bash and PowerShell) are read by a scanner driven by a rule table stated per language, and each language's panel names the reference its rules come from and anything they do not cover.
Those rules are not decoration. Rust, Swift and Kotlin nest block comments and C, Java and Go do not. A shell single-quoted word has no escape at all, so a backslash in one is a backslash. PowerShell escapes with a backtick, not a backslash, so a Windows path inside a double-quoted string has no escapes in it. Python treats the r in a raw string as part of the string token, and reads the expressions inside a formatted string as code. Each of those was checked against that language's own tokenizer or against a second statement of its rules written independently.
The result carries a self check: the tokens have to cover every character of your input exactly once and spell it back unchanged, and the page shows whether they did. Seven themes are available, and the colours are real colour values rather than class names, so the HTML you copy or export renders the same colours anywhere you paste it.
Generate syntax-highlighted snippets for technical writing, and copy the markup with its colours already in it rather than a set of class names your site may not define.
Export a PNG of the snippet at the font size and theme you chose, drawn from the same tokens the preview shows.
Embed correctly coloured examples, including ones holding URLs, regular expressions and quoted text that trip pattern-based highlighters.
Because the colouring comes from a lexer, an unterminated string or a comment that swallows the rest of a file shows up immediately as a whole block in the wrong colour.
Twenty-two: JavaScript, TypeScript, Python, Java, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, HTML, CSS, SCSS, JSON, YAML, XML, SQL, Bash, PowerShell and Markdown.
It is measured. A corpus of snippets, each chosen because a pattern-based highlighter gets it wrong, is scored against an independent decider per language: TypeScript's own scanner for JavaScript and TypeScript, Python's own tokenize module for Python, Python's html.parser for HTML, PyYAML for YAML, and a second statement of the rules for the rest. The current version agrees with those deciders on every character of all 44 snippets, both in the module and through this page.
Because the dialects disagree about what ends a string. Only MySQL treats a backslash inside a literal as an escape, the identifier delimiter differs across all five, and PostgreSQL alone has nested block comments and dollar quoting. Getting that wrong means a highlighter can decide a string ends in the wrong place.
Yes. "Copy HTML" gives you the markup with the colours written into each element, and "Export HTML" gives you a standalone file. Neither depends on a stylesheet you have to add.
It is the tool checking itself. The tokens it colours from have to cover every character of your input exactly once and spell your input back unchanged; the line reports whether they did. If it ever turns red, that is a fault worth reporting with the code that caused it.
No. Everything runs in your browser.
Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.