{"id":28230487,"url":"https://github.com/amarienko/terminalformatters","last_synced_at":"2026-04-12T16:03:32.338Z","repository":{"id":61547367,"uuid":"553199905","full_name":"amarienko/TerminalFormatters","owner":"amarienko","description":"Terminal font style and base 16 colors formatters","archived":false,"fork":false,"pushed_at":"2022-10-18T20:38:31.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T02:38:43.794Z","etag":null,"topics":["colors","formatter","python","python-cli","terminal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amarienko.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-17T21:51:34.000Z","updated_at":"2023-01-13T15:53:18.000Z","dependencies_parsed_at":"2022-10-19T22:31:09.843Z","dependency_job_id":null,"html_url":"https://github.com/amarienko/TerminalFormatters","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/amarienko/TerminalFormatters","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarienko%2FTerminalFormatters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarienko%2FTerminalFormatters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarienko%2FTerminalFormatters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarienko%2FTerminalFormatters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amarienko","download_url":"https://codeload.github.com/amarienko/TerminalFormatters/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarienko%2FTerminalFormatters/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001101,"owners_count":26082991,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["colors","formatter","python","python-cli","terminal"],"created_at":"2025-05-18T17:14:57.819Z","updated_at":"2025-10-09T08:15:29.047Z","avatar_url":"https://github.com/amarienko.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|Python Version| |License MIT| |PyPI| |Test Package| |Black badge|\n\nTerminal Formatters\n===================\n\nSimple Python package for producing colored and formated terminal text.\n\n|colored-text-python|\n\nTerminals traditionally take an input of bytes and display them as white\ntext on a black background. But if the input contains specific CSI\n(Control Sequence Introducer) sequences then the terminal may alter\ncertain display properties of the text, such as the style or color.\nUsing styles and colors in console applications helps us analyze\ninformation faster and focus on important parts of the displayed\ninformation.\n\nThe package creates ANSI escape character sequences for changing the\ncolor and style of the font, based on human-readable parameters like\n``black``, ``green``, ``italic`` etc.\n\nANSI Escape Codes for Terminal Graphics\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe `ANSI escape code\nstandard \u003chttps://en.wikipedia.org/wiki/ANSI_escape_code\u003e`__, formally\nadopted as `ISO/IEC\n6429 \u003chttps://www.ecma-international.org/publications/standards/Ecma-048.htm\u003e`__,\ndefines a series of control sequences. Each control sequence begins with\na *Control Sequence Introducer* (CSI), defined as an escape character\nfollowed immediately by a bracket: ``ESC[``. The ANSI ASCII standard\nrepresents the escape ESC character by the decimal number 27 (33 in\noctal, 1B in hexadecimal). The ``ESC[`` is followed by any number\n(including none) of \"parameter bytes\" in the range ``0x30–0x3F`` (ASCII\n``0–9:;\u003c=\u003e?``), then by any number of \"intermediate bytes\" in the range\n``0x20–0x2F`` (ASCII ``space`` and ``!\"#$%\u0026'()*+,-./)``, then finally by\na single \"final byte\" in the range ``0x40–0x7E`` (ASCII\n``@A–Z[\\]^_``\\ a–z{|}~`).\n\nAll common sequences just use the parameters as a series of\nsemicolon-separated numbers. Missing numbers are treated as 0 and no\nparameters at all in ``ESC[m`` acts like a 0 reset code.\n\nSelect Graphic Rendition (SGR) parameters\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe control sequence ``CSI n m``, named *Select Graphic Rendition*\n(SGR), sets display attributes. Several attributes can be set in the\nsame sequence, separated by semicolons. Each display attribute remains\nin effect until a following occurrence of SGR resets it. If no codes are\ngiven, ``CSI m`` is treated as ``CSI 0 m`` (reset / normal).\n\nThe package uses only basic parameters to control the font style and its\ncolor. The most commonly used SGR parameters to control the font style\nin the range (0-8) and the 8 actual colors within the ranges (30-37,\n40-47, 90-97, 100-107) are defined by the ANSI standard. The package put\nthese parameters together to create a full SGR command.\n\nThe original specification only had 8 colors, and just gave them names.\nThe SGR parameters ``30–37`` selected the foreground color, while\n``40–47`` selected the background. Quite a few terminals implemented\n\"bold\" (SGR code ``1``) as a brighter color rather than a different\nfont, thus providing 8 additional foreground colors. Usually you could\nnot get these as background colors, though sometimes inverse video (SGR\ncode 7) would allow that. Examples: to get black letters on white\nbackground use ``ESC[30;47m``, to get red use ``ESC[31m``, to get bright\nred use ``ESC[1;31m``. To reset colors to their defaults, use\n``ESC[39;49m`` (not supported on some terminals), or reset all\nattributes with ``ESC[0m``. Later terminals added the ability to\ndirectly specify the \"bright\" colors with ``90–97`` and ``100–107``.\n\nThe following diagram shows the complete text style and color rendering\nscheme.\n\n|how-to-print-colored-text-in-python|\n\nThe package supports the parameters shown in the tables below:\n\nFont Styles\n^^^^^^^^^^^\n\n+-----------+---------------------------+---------------------------+\n| Parameter | Name                      | Note                      |\n+===========+===========================+===========================+\n| 0         | Reset or normal           | All attributes off        |\n+-----------+---------------------------+---------------------------+\n| 1         | Bold or increased         | As with faint, the color  |\n|           | intensity                 | change is a PC (SCO/CGA)  |\n|           |                           | invention                 |\n+-----------+---------------------------+---------------------------+\n| 2         | Faint, decreased          | May be implemented as a   |\n|           | intensity, or dim         | light font weight like    |\n|           |                           | bold                      |\n+-----------+---------------------------+---------------------------+\n| 3         | Italic                    | Not widely supported.     |\n|           |                           | Sometimes treated as      |\n|           |                           | inverse or blink          |\n+-----------+---------------------------+---------------------------+\n| 4         | Underline                 | Style extensions exist    |\n|           |                           | for Kitty, VTE, mintty    |\n|           |                           | and iTerm2                |\n+-----------+---------------------------+---------------------------+\n| 5         | Blink or Slow blink       | Sets blinking to less     |\n|           |                           | than 150 times per minute |\n+-----------+---------------------------+---------------------------+\n| 7         | Negative, Reverse or      | Swap foreground and       |\n|           | invert                    | background colors;        |\n|           |                           | inconsistent emulation    |\n+-----------+---------------------------+---------------------------+\n| 8         | Conceal or hide           | Not widely supported      |\n+-----------+---------------------------+---------------------------+\n\nForeground/Background Colors\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n========== ========== ====================\nForeground Background Name\n========== ========== ====================\n30         40         Black\n31         41         Red\n32         42         Green\n33         43         Yellow\n34         44         Blue\n35         45         Magenta\n36         46         Cyan\n37         47         White\n90         100        Black Bright or Grey\n91         101        Red Bright\n92         102        Green Bright\n93         103        Yellow Bright\n94         104        Blue Bright\n95         105        Magenta Bright\n96         106        Cyan Bright\n97         107        Bright\n========== ========== ====================\n\nTest scripts in the source code repository print formatted/colored\ntables using supported ANSI sequences. The following styles and colors\nworks with most terminal applications.\n\n|colored-style--python|\n\n|colored-text--python|\n\nThe package has no requirements other than the standard library.\n\nUsage\n~~~~~\n\nHow to use the module in your own python code:\n\n.. code-block:: python\n\n   from termformatters import StyleFormatters\n   from termformatters import ForegroundFormatters\n   from termformatters import BackgroundFormatters\n\n   \"\"\"Creating Formatters Instances\"\"\"\n   S = StyleFormatters()\n   FG = ForegroundFormatters()\n   BG = BackgroundFormatters()\n\n   print(FG.green(\"Printing `Green` colored text\"))\n   print(FG.cyan(\"Printing `Cyan` colored text\"))\n   print(\n       S.bold(\n           FG.white_bright(\n               \"Printing `Bold` and `White Bright` text\"\n           )\n       )\n   )\n   print(\n       FG.yellow(\n           BG.blue_bright(\n               \"Printing `Yellow` text on `Blue` background\"\n           )\n       )\n   )\n\nReferences\n~~~~~~~~~~\n\n-  `ANSI escape code\n   standard \u003chttps://en.wikipedia.org/wiki/ANSI_escape_code\u003e`__\n-  `ISO/IEC\n   6429 \u003chttps://www.ecma-international.org/publications/standards/Ecma-048.htm\u003e`__\n\n.. |colored-text-python| image:: https://user-images.githubusercontent.com/101603641/195454314-e0b5352f-3312-496a-a9aa-1f67ac370efc.jpg\n.. |how-to-print-colored-text-in-python| image:: https://user-images.githubusercontent.com/101603641/195437212-1de20dbd-47ce-43fa-826f-e8f069813e3b.jpg\n.. |colored-style--python| image:: https://user-images.githubusercontent.com/101603641/195454430-4856cf8d-3a71-4584-b462-cf56430c5d64.gif\n.. |colored-text--python| image:: https://user-images.githubusercontent.com/101603641/195454450-625c2d22-0b2e-4db0-8016-7c4cafad6116.jpg\n.. |Python Version| image:: https://img.shields.io/pypi/pyversions/termformatters\n   :target: https://www.python.org/downloads/\n.. |License MIT| image:: https://img.shields.io/github/license/amarienko/TerminalFormatters?color=yellow\n   :target: https://opensource.org/licenses/MIT\n.. |PyPI| image:: https://img.shields.io/pypi/v/termformatters\n   :target: https://pypi.org/project/termformatters/\n.. |Test Package| image:: https://github.com/amarienko/TerminalFormatters/actions/workflows/termformatters-main-lint-and-test.yaml/badge.svg?branch=main\n   :target: https://github.com/amarienko/TerminalFormatters/actions/workflows/termformatters-main-lint-and-test.yaml\n.. |Black badge| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/psf/black\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarienko%2Fterminalformatters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famarienko%2Fterminalformatters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarienko%2Fterminalformatters/lists"}