A tiny Python library for turning ASCII grids into colorful images. It is designed for quick visualizations of mazes, maps, game boards, and Advent of Code-style 2D text puzzles.
- Turn a rectangular text grid into a rendered image in a few lines
- Map each character to a color automatically or via your own palette
- Support multiple rendering styles for cells, text, and background-label combinations
- Works well for generative art, puzzle visualizations, and debugging text-based layouts
string_to_image()for direct text-to-image conversionfile_to_image()for processing a text file as a grid- Preset colormaps such as
viridis,plasma, andterrain - Custom
value_colorsdictionaries for full control over mapping - Render modes: filled cells, colored text, and colored cells with background text
- Comes bundled with
RobotoMono-Regular.ttf- Provide a path to any true type font to use that instead!
pip install paintbycharimport paintbychar as pbc
grid = """0123
4567
89AB
"""
img = pbc.string_to_image(
grid,
preset="viridis",
cell_size=24,
render_style=pbc.RenderStyle.COLORED_CELLS,
)
pbc.save_image(img, "output_basic.png")The repository includes several runnable examples in the examples/ folder, including:
basic_example.pyfile_example.pystyles_example.pypreset_example.pyadvent_of_code_example.py
See the documentation for a quick overview of the public functions and options, or browse the live docs site.
There is also documentation on Read the Docs with installation instructions, usage examples, and API reference. Read the Docs
Contributions are welcome. See CONTRIBUTING.md for setup instructions, testing guidance, and the pull request process.
This project follows the Contributor Covenant Code of Conduct.
This project is licensed under the MIT License.
The bundled Roboto Mono font is separately licensed under the SIL Open Font License (OFL). See src/fonts/OFL.txt for its license terms.
PaintByChar is currently a small, focused library aimed at grid-based text rendering and visualization. It is suitable for personal, educational, and open-source use, and is prepared for broader community contributions as it matures.
A repository preview image is included in assets/social-preview.png and can be used as a GitHub social preview or banner asset.



