ANSI to HTML Converter
Convert terminal output with ANSI colour codes to HTML that keeps the colours, or strip the escape codes to get plain text.
Free · No sign-up · Your inputs stay in your browser
Input
Convert ANSI colour codes to HTML, or strip them
Output
Preview
✓ 42 tests passed warning: deprecated option --legacy error: connection refused (port 5432) at Socket.connect (net.js:1141:16)
HTML
<pre class="terminal"><span style="color:#57ab5a;font-weight:700">✓</span> 42 tests passed <span style="color:#c69026">warning</span>: deprecated option <span style="font-weight:700">--legacy</span> <span style="color:#e5534b;font-weight:700">error</span>: connection refused (<span style="color:rgb(255,135,0)">port 5432</span>) <span style="opacity:.7"> at Socket.connect (net.js:1141:16)</span></pre>
Reads SGR codes: bold, dim, italic, underline, the 16 standard colours, the 256-colour palette (38;5;n) and 24-bit colour (38;2;r;g;b); cursor movement and window titles are dropped. Many tools stop colouring when output is not a terminal: pass --color=always (or FORCE_COLOR=1) to capture the codes.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Logs that look broken
CI logs, docker logs and files written by tools that colour their output are full of escape sequences that show up as garbage outside a terminal. Stripping them makes the log searchable; converting them keeps the colours for a bug report or documentation. Many tools stop colouring when output is not a terminal; flags such as --color=always or the FORCE_COLOR environment variable turn it back on.
The codes
An SGR sequence is ESC, then [, then numbers separated by semicolons, then m: 31 sets red text, 1 bold, 0 resets, 38;5;n selects from the 256-colour palette and 38;2;r;g;b a true colour. The codes are defined in ECMA-48 and listed in the ANSI escape code article.