Library of Congress Classification to JSON
lcc2json outputs a single JSON file of the
Library of Congress Classification system.
For input, it downloads 699 .json files, 14 megabytes in total,
from the Library of Congress.
Install
Install from PyPI:
pip install lcc2json
Or install from main source repo, such as:
git clone https://spacecruft.org/books/lcc2json
cd lcc2json/
python -m venv venv
source venv/bin/activate
pip install -U setuptools pip wheel
pip install -e .
Usage
Thusly.
Download the source JSON files from the Library of Congress
lcc2json-dl
Parse the downloaded JSON files and output a single JSON file:
lcc2json
Help
Download script help:
(venv) jebba@rs-pencil:~/devel/spacecruft/books/lcc2json$ lcc2json-dl --help
usage: lcc2json-dl [-h] [-o OUTPUT_DIR] [-d MAX_DEPTH] [-v] [--dry-run]
Download Library of Congress Classification JSON files from id.loc.gov
options:
-h, --help show this help message and exit
-o, --output-dir OUTPUT_DIR
Output directory for JSON files (default: json)
-d, --max-depth MAX_DEPTH
Maximum depth to crawl (default: 2)
-v, --verbose Enable verbose logging
--dry-run Show what would be downloaded without actually downloading
Examples:
lcc2json-dl # Download all classifications to ./json/ (depth 2)
lcc2json-dl --max-depth 4 # Download to depth 4 (includes subdivisions)
lcc2json-dl -o lcc_data # Download to ./lcc_data/
lcc2json-dl -v # Verbose output
lcc2json-dl --dry-run # Show what would be downloaded
Depth levels:
0 = Root classification scheme
1 = Main classes (A-Z)
2 = Subclass ranges (e.g., PR1-PR9680) [default]
3 = Period/topic divisions (e.g., PR6050-PR6076)
4 = Alphabetical ranges (e.g., PR6066.A-PR6066.Z)
5+ = Individual entries (e.g., PR6066.A84)
Output JSON script help:
$ lcc2json --help
usage: lcc2json [-h] [-i INPUT_DIR] [-o OUTPUT] [-v] [--ranges]
Extract LCC outlines from downloaded JSON files.
options:
-h, --help show this help message and exit
-i, --input-dir INPUT_DIR
Directory containing JSON files (default: json)
-o, --output OUTPUT Output file path (default: lcc.json)
-v, --verbose Enable verbose output
--ranges Include start/stop/prefix range fields in output (larger file size)
JSON Data
Depth 1
- 21 files.
- ~5 second download.
- 215K size.
- 21 classification entries.
Depth 2
- 698 files.
- 2 minute download.
- 14M size.
- 14,786 classification entries.
- 516 unique prefixes.
Depth 3
- 14,581 files.
- 2 hour download.
- 161M size.
- 101,699 classification entries.
Depth 4
- 100,551 files.
- 14 hour download.
- 824M size.
- 344,073 classification entries.
- Two missing (404) files.
Depth 5
- 342,499 files.
- 2 day download.
- 2.9G size.
- 766,892 classification entries.
- Three missing files.
Downloads
JSON data snapshots are also available at this URL, so, optionally you don't have to download with this script:
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright © 2025 Jeff Moe
Metadata
Release files for lcc2json 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lcc2json-1.4.0.tar.gz | 18.6 kB | Without provenance | Details for lcc2json-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lcc2json-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for lcc2json-1.4.0-py3-none-any.whl |
Total release size: 36.4 kB
Release files / lcc2json-1.4.0.tar.gz
| Download URL | lcc2json-1.4.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8731bd44730de97a0959e5441c6c8b4fd8d27a0c4827dba01daac3cea1460edd
|
|
BLAKE2b-256 checksum How to use checksums |
bc81dd58c429a16c70252d282fc9577c490950539f0ef0d42e5a855b3eb4ff41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / lcc2json-1.4.0-py3-none-any.whl
| Download URL | lcc2json-1.4.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c2beb96cbfc67ea416196b86523c3cff8876cfd72541c0b6d25f7f3b7045966
|
|
BLAKE2b-256 checksum How to use checksums |
188668f457762213c83e90399919b176536ba1cf1f52b8f1a9c210a8e169e706
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for lcc2json 1.4.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.