This release is a pre-release and may not be stable for production use.
txthighlight
A tiny local web app for highlighting and commenting on plain text files.
Installation
pip install txthighlight
Usage
Two subcommands: serve (start the web UI) and extract (export highlights).
serve — highlight text in the browser
Serve the current directory:
txthighlight serve
Serve a single file:
txthighlight serve --host 0.0.0.0 --port 8080 somefile.txt
Serve a directory:
txthighlight serve --host 0.0.0.0 --port 8080 ./docs
Then open:
http://0.0.0.0:8080
If you serve a directory, / shows a simple directory listing and you can click into files or subdirectories. The listing visually marks directories, likely annotatable text files, .json sidecars, and other files.
extract — export highlighted text
Once you've highlighted passages in a file, extract them from the command line:
txthighlight extract somefile.txt
By default it prints each highlighted passage on its own line.
Use --format to control the output:
# Plain text (default) — one highlighted span per line
txthighlight extract somefile.txt
# Markdown — highlights as blockquotes with comments
txthighlight extract --format markdown somefile.txt
# JSON — full annotation data including offsets and comments
txthighlight extract --format json somefile.txt
The extract command reads the <file>.txt.json sidecar that was created while highlighting. It does not require the server to be running.
Highlight metadata is stored next to the source file in:
somefile.txt.json
Only UTF-8 text files are supported. Non-UTF-8 files are rejected with an error.
What it does
- renders a plain text file in the browser
- lets you select text and highlight it
- lets you add comments to highlights
- lets you remove highlights
- stores annotation data locally in a JSON sidecar file
- works with desktop and mobile browsers
- extracts highlighted text via CLI (plain text, markdown, or JSON)
Why this exists
There are many tools for annotating PDFs, rich text documents, and web pages. There are very few simple tools for annotating a raw local text file.
Plain text is still a common working format for:
- transcripts
- logs
- OCR output
- legal or policy text
- prompt corpora
- research notes
- interview notes
- exported chat histories
This project fills that narrow gap: plain text in, annotations in a nearby JSON file, no database required.
The niche
This tool lives in an awkward but useful niche.
Most annotation tools assume one of these:
- HTML pages annotated by a browser extension
- rich text documents like Word or Google Docs
- PDF with built-in annotation support
- note-taking apps with their own storage format
But sometimes you do not want any of that. Sometimes you have a .txt file and want to keep working with a .txt file.
Data format
Annotations are stored in <text-file>.json.
Example:
{
"source_file": "/path/to/somefile.txt",
"annotations": [
{
"id": "3d7278a2-6d67-4e1c-a0c8-4a0a7d3b0e40",
"start": 12,
"end": 42,
"comment": "Important passage",
"created_at": 1713350000,
"updated_at": 1713350123
}
]
}
Offsets are character offsets into the text file as loaded by the app.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Release files for txthighlight 0.1.0a7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| txthighlight-0.1.0a7.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| txthighlight-0.1.0a7-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 25.9 kB
Release files / txthighlight-0.1.0a7.tar.gz
| Download URL | txthighlight-0.1.0a7.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24ed735d2f2c4aa572aefadbfe963a738502a2d47cf2388fc49aa6b51ff7d8b3
|
|
BLAKE2b-256 checksum How to use checksums |
b27fb2e1bd35748a8de91d7ec94e5c6634348cc1259f6db38e257039adc5c7fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / txthighlight-0.1.0a7-py2.py3-none-any.whl
| Download URL | txthighlight-0.1.0a7-py2.py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
486cf2cea4653c3c09b4ae75c4c02ee8a0898048b942928f66c137d7985ce23e
|
|
BLAKE2b-256 checksum How to use checksums |
5c56f1a979f1b4f631e7199c9c44522e8ee361fb721a53e31b069507fa6e4c17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|