Skip to main content

puz.py: Python parser for .puz files

PyPI - Version PyPI - Downloads PyPI - License GitHub branch check runs Coverage

Python library to read and write crossword puzzle files in Across Lite .puz and .txt formats.

Installing

pip install puzpy

From source (for development)

uv sync --extra dev

Or with pip:

pip install -e .[dev]

Example Usage

import puz

#
# Load a puzzle file:
#
p = puz.read('testfiles/washpost.puz')

#
# Print all clues and their answers
#
clues = p.clue_numbering()

print('Across')
for clue in clues.across:
    print(f'{clue.number}. {clue.text} - {clue.solution}')

print('Down')
for clue in clues.down:
    print(f'{clue.number}. {clue.text} - {clue.solution}')

#
# Print the puzzle grid
#
for row in p.grid():
    print(' '.join(row))

#
# Unlock a puzzle that has a locked solution
#
p.unlock_solution(7844)

# Now print the unscrambed solution grid:
for row in p.solution_grid():
    print(' '.join(row))

#
# Save a puzzle with modifications:
#
p.fill = 'LAMB' + p.fill[4:]
p.save('example.puz')

#
# New! Convert from Across Lite text format to .puz:
#
p2 = puz.read_text('testfiles/text_format_v1.txt')
p2.save('example.puz')

Notes

The parser is as strict as Across Lite, enforcing internal checksums and magic strings. The parser is designed to round-trip all data in the file, even fields whose utility is unknown. This makes testing easier. It is resilient to garbage at the beginning and end of the file (for example some publishers put the filename on the first line and some files have a rn at the end).

In addition to the handful of tests checked in here, the library has been tested on over 9700 crossword puzzles in .puz format drawn from the archives of several publications including The New York Times, The Washington Post, The Onion, and, the Wall Street Journal. As of writing, it can round-trip 100% of them with full fidelity.

Running tests

Build and run tests

Unit tests

uv run pytest

Lint

uv run ruff check

Type check

uv run pyright

Viewer

This repo includes a puz file viewer. The script renders a .puz or .txt file as a print-ready stand-alone HTML file. Its only dependency is puz.py. Examples: 15x15, 21x21, ...

$ python puz_viewer.py --help
usage: puz_viewer.py [-h] [-o OUTFILE] [--outdir OUTDIR] [-f {auto,puz,txt}] [--index] [puzzles ...]

Generate an HTML viewer for a crossword puzzle or puzzles

positional arguments:
  puzzles               Paths to .puz or .txt files (default: stdin)

options:
  -h, --help            show this help message and exit
  -o, --outfile OUTFILE
                        Output HTML filename (default: stdout, or auto-generated from input filename in batch mode)
  --outdir OUTDIR       Output directory for HTML files (default: .)
  -f, --format {auto,puz,txt}
                        Input format (default: auto-detect)
  --index               Generate index.html in output directory (batch mode)

Python version support

PyPI - Python Version

Python >=3.9 required since 0.3.1. For older python versions including 2.x use puzpy==0.2.6

Resources

License

MIT License.

Metadata

Release files for puzpy 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for puzpy 0.7.0
File Size Uploaded Provenance Actions
puzpy-0.7.0.tar.gz 20.8 kB With provenance Details for puzpy-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for puzpy 0.7.0
File Interpreter ABI Platform Actions
puzpy-0.7.0-py3-none-any.whl Python 3 none any Details for puzpy-0.7.0-py3-none-any.whl

Total release size: 37.5 kB

Release files / puzpy-0.7.0.tar.gz

Download URL puzpy-0.7.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
098a1a2250861e6cac87553d4d52a947646bc65946951b0793687d73e9e9a967
BLAKE2b-256 checksum
How to use checksums
9f45d4901543bc78905d9e443e8f340126515105b5e5e69598860aa6f1c25c83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / puzpy-0.7.0-py3-none-any.whl

Download URL puzpy-0.7.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee67f3f9dbd1d871393ef8d7afda988b3af378e3da2cf34a90cf7b6ade656f54
BLAKE2b-256 checksum
How to use checksums
cd4bf2f0585e7edb0bb67050c13c32805879439a5ad85e3aa5a281aecfb768f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for puzpy 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for puzpy-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page