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

From pypi (recommended)

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.

Release files for puzpy 0.6.1

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.6.1
File Size Uploaded
puzpy-0.6.1.tar.gz 20.0 kB Details

Built distribution (wheel)

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

Total release size: 36.2 kB

Release files / puzpy-0.6.1.tar.gz

Download URL puzpy-0.6.1.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7ec6b7e51f1a3a09af6ccd8f1b54c9e5cd95da347e340b88bac933c4d9fa7f63
BLAKE2b-256 checksum
How to use checksums
459f51f3bb801f8d0146ed6687861bf9323e59cf872b881ae5282c966f6fcd0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Apr 25, 2026.

Transparency log

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

Download URL puzpy-0.6.1-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
445c14d881dc37a723eb3527dd9baa649ec309a87fddc874e94ddaedbe483ec1
BLAKE2b-256 checksum
How to use checksums
065e1fb75637f9889a948eca4012ddeff404c5962ab657d97aa18aea460e35a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Apr 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

1 release file

0.2.2

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

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