ANSI Log → HTML
Render an ANSI-colored terminal log as styled HTML.
Overview
The ANSI-to-HTML converter takes terminal output peppered with escape sequences like \x1b[31m and turns it into styled HTML you can paste into a wiki, ticket, or status report. Colours, bold, underline, and dim styles all survive the trip, so a CI failure log keeps the same red FAIL lines a reader would see in their shell.
It's the fastest way to share build output, test runs, or kubectl logs in a place that doesn't render ANSI codes. Engineers, DevOps folks, and tech writers use an ansi log converter when copying console output into Confluence, GitHub issues, or internal docs without losing the colour cues that highlight errors.
How it works
The converter walks the input character by character and tracks an SGR (Select Graphic Rendition) state machine. Each CSI ... m sequence flips foreground, background, or intensity bits, and a corresponding <span style="..."> is emitted with the resulting CSS. Both the 16-colour palette and the 256-colour palette are mapped to standard sRGB values; truecolour 38;2;r;g;b sequences pass through with their exact RGB.
Cursor-movement, screen-clear, and OSC sequences are stripped silently so noisy progress bars don't leak through. The output is wrapped in a <pre> so whitespace and line breaks survive.
Examples
Input:
\x1b[32mPASS\x1b[0m UserServiceTests
\x1b[31mFAIL\x1b[0m AuthServiceTests
Output:
<pre><span style="color:#0a0">PASS</span> UserServiceTests
<span style="color:#a00">FAIL</span> AuthServiceTests</pre>
Input: \x1b[1;33mwarning:\x1b[0m deprecated API
Output: <span style="color:#aa0;font-weight:bold">warning:</span> deprecated API
FAQ
Does it handle 24-bit truecolour?
Yes. Sequences like \x1b[38;2;120;200;255m are mapped directly to rgb(120,200,255) so gradient-style coloured output renders identically.
What about hyperlinks emitted with OSC 8?
OSC 8 link sequences are recognised and turned into <a href="..."> tags wrapping the visible text, so clickable links from modern terminals survive.
Can I get the styles in a separate stylesheet instead of inline?
Inline style attributes are the default because they survive copy/paste into rich-text editors. For long logs you can swap to class-based output and supply your own CSS.