{"id":13583280,"url":"https://github.com/bahmutov/term-to-html","last_synced_at":"2025-09-28T23:31:29.642Z","repository":{"id":46575900,"uuid":"239904348","full_name":"bahmutov/term-to-html","owner":"bahmutov","description":"Stream terminal output with ansi codes into nicely formatted HTML","archived":false,"fork":false,"pushed_at":"2022-03-26T14:54:49.000Z","size":2050,"stargazers_count":26,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-27T20:50:01.225Z","etag":null,"topics":["ansi","cli","html","term"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-12T01:48:15.000Z","updated_at":"2024-07-04T04:35:25.000Z","dependencies_parsed_at":"2022-08-30T17:20:30.887Z","dependency_job_id":null,"html_url":"https://github.com/bahmutov/term-to-html","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fterm-to-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fterm-to-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fterm-to-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fterm-to-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/term-to-html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234570384,"owners_count":18854156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","cli","html","term"],"created_at":"2024-08-01T15:03:22.573Z","updated_at":"2025-09-28T23:31:29.171Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# term-to-html [![CircleCI](https://circleci.com/gh/bahmutov/term-to-html/tree/master.svg?style=svg)](https://circleci.com/gh/bahmutov/term-to-html/tree/master)\n\n\u003e Stream terminal output with ansi codes into nicely formatted HTML\n\nImagine you have terminal output, let's say from a test runner. It looks like this\n\n![terminal output](images/term.png)\n\nYou can pipe the output through `term-to-html` to create equivalent HTML file. Same output (HTML page was white background)\n\n![html](images/html.png)\n\nThe output could be used to do [visual testing against CLI output](https://glebbahmutov.com/blog/visual-diffing-for-CLI-apps/)\n\n## Use\n\n```shell\nnpm i -g term-to-html\nmocha spec.js --reporter spec | term-to-html \u003e mocha.html\n```\n\n**Note:** many applications detect non-interactive terminal and turn off colors. Usually you can enable colors using an environment variable, like `FORCE_COLOR=2` in [chalk](https://github.com/chalk/chalk) library.\n\n### Dark theme\n\nYou can output HTML page with dark background using `--theme dark` CLI argument\n\n```shell\n\u003cmy program\u003e | term-to-html --theme dark\n```\n\n### Use as a module\n\n```js\nconst termToHtml = require('term-to-html')\nconst html = termToHtml.strings(stringWithAnsi, termToHtml.themes.dark.name)\n```\n\n## Testing\n\nThere are [E2E tests](e2e.js) and you can observe the output by running\n\n```shell\nFORCE_COLOR=2 npx mocha spec.js --reporter spec | ./bin/term-to-html.js\n```\n\n### Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2020\n\n- [@bahmutov](https://twitter.com/bahmutov)\n- [glebbahmutov.com](https://glebbahmutov.com)\n- [blog](https://glebbahmutov.com/blog)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/term-to-html/issues) on Github\n\n## MIT License\n\nCopyright (c) 2020 Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/term-to-html.svg?downloads=true\n[npm-url]: https://npmjs.org/package/term-to-html\n[renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg\n[renovate-app]: https://renovateapp.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fterm-to-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fterm-to-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fterm-to-html/lists"}