Syntax Highlighter
Colour A Listing, Copy The Markup
This syntax highlighter tokenises a file into strings, comments, keywords and numbers, then paints each one. Copy the result as escaped HTML, as a word processor block, or as plain text with the colour stripped out. Nothing you paste leaves the browser.
- FreePrice
- 12Languages
- 4Outputs
- NoneUploads
Syntax Highlighter
Colour a listing in twelve languages, then copy escaped HTML, a word processor block, plain text or the stylesheet
If you use a screen reader, the plain text tab is the readable copy: the coloured ones carry a span around every token.
Ready. Paste a listing, or press one of the sample buttons.
What A Syntax Highlighter Does
A colour is a claim about what a piece of text is. Therefore a highlighted listing is easier to read. The reader learns the shape of a file before reading a line of it.
That is the whole job of this syntax highlighter. It splits the text into tokens, decides what each one is, and gives each class a colour.
It knows twelve languages, and it treats a string, a comment, a keyword, a number and a name as different things. Because the decision comes from a tokeniser rather than from a pattern match, a keyword inside a comment stays a comment.
Four outputs come out of one run. Escaped HTML to paste into a page, a word processor block, plain text, and a small stylesheet for the colours alone.
Everything runs in this tab. Therefore an unfinished listing gets coloured exactly like a shipped one.
How A Syntax Highlighter Splits Code Into Tokens
The reader walks the text once, carrying a state and a stack. At each character it decides whether it sits inside a string, a comment, a number or ordinary code. It emits a token when that state changes.
A keyword list per language supplies the rest. The list is short on purpose, because the useful question is which words the language reserves. That reserved list is what the standard documents publish.
Because the reader carries that state, a word inside a comment is not a keyword. This is the difference between a highlighter and a find and replace. It is also the first thing to look at when a coloured listing looks wrong.
A language that nests block comments needs a depth counter rather than a flag. One that allows a template literal needs a stack. Both are held so that an inner delimiter cannot end an outer block.
Nothing here changes the text a reader gets. A copy of the plain output is byte for byte what you pasted, which matters when the listing came out of a terminal.
Why The Output Escapes Before It Colours
Highlighted code is markup, and markup pasted into a page is markup the browser runs. So the angle brackets in a listing have to become entities before anything else happens.
That is not a formatting detail. A snippet copied from an issue tracker can carry a script tag, and a page that pastes it raw has just run a stranger's code.
Every output here escapes first and colours second. Because the escape happens before the tool writes a single span, a listing cannot introduce an element of its own.
The same rule covers an attribute. A comment that holds a quotation mark goes into the text of the span rather than into an attribute. So it cannot close anything early.
That is why the HTML output is worth copying from here rather than from an editor that colours for display only. The colours look identical and only one of them is safe to paste.
The Twelve Languages, And What Each One Needs
Four of them share a grammar with a sibling. JavaScript, TypeScript and JSON sit close enough together that one reader covers all three. CSS and SCSS share a reader the same way.

The C family adds a preprocessor line. The reader takes a hash line on its own before it tokenises the rest of the line. That is why include and define come out a different colour from the code around them.
Python and Ruby both need indentation awareness. A triple quoted string and a heredoc do not end at a newline. So the reader has to keep the string open across lines.
PHP and HTML interleave, so the reader switches mode at the opening tag. Because the two grammars are different, a single pass that ignored the switch would colour the HTML as though it were PHP.
SQL and Bash are the last two, and both are line oriented. A comment marker differs between them, which is the sort of detail that decides whether a listing reads correctly.
The Four Outputs, And When To Use Each
Escaped HTML is the first, and it is the one for a page. Each token becomes a span with a class. The tool escapes the text inside as entities, so the block drops into a post without any further work.

The word processor block is the second. Because a word processor ignores your stylesheet, the colours arrive as inline styles on each span, which survives a paste into a document.
Plain text is the third, and it keeps the indent and the line count without a single colour. Use it when the listing is going into a terminal or a commit message, where markup would be noise.
The stylesheet is the fourth. It carries the twelve colour rules with no markup attached. So a site that already wraps its own spans can adopt the palette without adopting the output.
How To Use The Syntax Highlighter
Four steps, and none of them need an account.
- 1
Pick the language
So choose from the twelve. The keyword list and the comment markers both come from this setting. Therefore a wrong choice is the usual reason a listing looks half coloured.
- 2
Paste the listing
Then paste the code. The indent is kept as pasted, so a file that is already laid out reads the way it does in an editor.
- 3
Set the gutter and the theme
Next, decide whether line numbers belong in the output and pick a light or a dark palette. Since both choices go into the markup, set them before you copy.
- 4
Copy the shape you need
Finally, take the HTML, the word processor block, the plain text or the stylesheet. After that, paste it wherever the listing belongs.
Why Use This Syntax Highlighter
Five reasons, and the second one is the one that matters most.
It escapes before it colours
Because the text is entity escaped first, a pasted listing cannot introduce an element or an attribute of its own. So the output is safe to put on a page.
It carries state, not patterns
A keyword inside a comment stays a comment, and a brace inside a string stays text. Therefore the colours match what the language actually means.
Four outputs from one run
A page, a word processor, a terminal and a stylesheet all want a different shape. So one paste covers whichever of them you need next.
Nothing uploads
Tokenising and colouring both happen in this tab alone. Hence an unreleased stylesheet gets identical handling.
The color rules are yours
The stylesheet output carries the palette with no markup attached. Hence a site that already wraps its own spans can adopt the colors and nothing else.
Habits That Keep A Listing Readable
Six habits that decide whether coloured code actually helps.
- Show the shortest snippet that proves the point A thirty line listing gets skimmed and a six line one gets read. Because a reader is looking for the shape rather than the whole file, trim before you colour.
- Keep the indent as the author wrote it Reindenting a snippet changes what it looks like in the file it came from. So leave the depth alone and let the reader match it against the source.
- Reach for the gutter only past ten lines Line numbers help when a reader has to cite a line. Under ten lines they are noise beside code that a reader can count.
- Match the palette to the page A dark block in a light article draws the eye away from the argument. Since both palettes are on offer, pick the one that agrees with the page around it.
- Copy the HTML rather than the rendered block Dragging a coloured block out of a browser loses the classes and keeps a mess of inline styles. Therefore use the copy button, which writes the markup you can read.
- Keep a plain text copy for the terminal Markup in a commit message or a shell session becomes characters rather than colour. So keep the plain output beside the coloured one.
Six Ways A Highlighted Listing Goes Wrong
Each of these looks fine in the preview and fails where it lands.
Pasting raw markup into a page
Watch out here. A listing pasted without escaping is markup the browser runs, and one script tag in a comment is enough. So use the HTML output rather than a copy from another editor.
Choosing the wrong language
A keyword list from one language leaves the words of another uncoloured. Because the result still looks deliberate, this is easy to ship by accident.
Expecting a template literal to end at a newline
A backtick keeps a string open across lines. Hence one unclosed template at the top colours the rest of the file as a single string, which reads as a tool bug.
Colouring a diff as source
A plus or a minus at the start of a line is not part of the language. So paste the two sides separately, or the first character of every line is already wrong.
Turning on the gutter for a copied snippet
A reader who copies a numbered listing gets the numbers with the code. Because the paste then fails to run, keep the gutter for a page a reader only reads.
Assuming the colours carry meaning
A colour alone is a weak signal for a reader who cannot see it. Therefore the words matter more than the palette, and a listing should still make sense without colour.
Syntax Highlighter Questions
Is this syntax highlighter free?
Yes. There is no account, no limit and no paid tier. So you colour as many listings as you like.
Which languages does it support?
Twelve: JavaScript, TypeScript, JSON, HTML, CSS, SCSS, PHP, Python, Ruby, Java, SQL and Bash. Four of them share a reader with a sibling.
Is the output safe to paste into a page?
The HTML output is, because the tool escapes the text as entities before it writes a single span. So a script tag inside a pasted snippet arrives as text rather than as an element.
Where do the angle brackets go?
They become entities, so the browser shows them rather than reading them as markup. That is the whole reason the escaped output exists.
Why is a keyword in my comment not coloured?
Because it is inside a comment, and the reader knows that. A highlighter that colours by spelling alone would get this wrong, and this one decides from the state.
Can I get the result without any markup?
Yes. The plain text output keeps the indent and the line count and adds no colour. That is the copy for a commit message or a terminal.
Does it work in a word processor?
Yes, through the word processor output. Because a document ignores a stylesheet, the colours arrive as inline styles on each span instead.
Can I use the colours on my own site?
Yes. The stylesheet output carries the twelve rules with no markup attached, so your own spans can adopt the palette.
Is my code uploaded anywhere?
No. The tokenising and the colouring both happen in this browser tab. So an unreleased file never crosses the network.
Does it change my code?
No. The plain output is byte for byte what you pasted, and the coloured output differs only in the spans around the text.
Can I highlight a whole file?
Yes. A file of a few thousand lines colours in a moment, and the limit is your machine rather than a server quota.
Does it check my code for errors?
No. A highlighter answers what a token is, not whether the program is valid. So run the validator for that question.
Can I highlight a diff?
Not directly, because a plus or a minus at the start of a line is not part of the language. So paste the two sides separately.
Does it number the lines?
Yes, if you ask it to. The gutter goes into the output, so decide before you copy, and leave it off for a snippet a reader might paste.
What is the light and dark option for?
It swaps the palette so the block agrees with the page around it. The tokens are the same either way, and only the colours move.
Does it handle a template literal across lines?
Yes. Because the reader keeps the string open at a newline, a multi line template colours as one string rather than as code.
Can I colour a listing for a slide?
The word processor output is the one for that. So paste the block into the document and it keeps its colours.
Why does my listing look half coloured?
The usual cause is an unclosed string or comment above it, which swallows the lines after it. So check the top of the paste first.
Does it work on a phone?
Yes. The panes stack and the tabs wrap into rows. So a short listing is possible away from a desk, though a long file is easier on a keyboard.
Do I need an account or an extension?
No. There is no sign-up, no plugin and no extension to add. So you close the tab once the listing is on the clipboard.
Tools That Go With This One
Four pages the same job usually leads to.
HTML entity encoder
The escaping step on its own. Because a snippet can carry markup, encoding the angles first is the habit worth keeping.
Open tool →Code beautifier
A listing reads better once the layout is steady. So reindent the file before you colour it.
Open tool →JavaScript minifier
Once the block is on a page, the script beside it can shrink. So the download a visitor waits for gets smaller.
Open tool →HTML minifier
Once the block is on a page, the markup around it can shrink. Since a browser downloads every comment, that is the last step.
Open tool →
Colour The Listing And Copy The Markup
Pick the language, paste the code, choose a palette and take the output shape you need. Nothing uploads, and the tool escapes the text before it colours anything, so the block is safe to put on a page. Most listings are ready before the tea goes cold.