Skip to main content

ANDF — AI Native Document Format

ANDF (.andf) is a document format built for AI-native workflows. Every .andf file is a self-contained HTML file that:

  • Opens in any browser instantly — looks and feels like a PDF (toolbar, dark background, white pages, page numbers)
  • Is trivially parseable by AI — structured JSON is embedded in a <script type="application/andf+json"> tag
  • Requires no install, no server, no extension

Quick Start

from andf import ANDFDocument

doc = ANDFDocument()
doc.set_metadata(title="My Report", authors=["Alice"])

sec = doc.add_section("intro", "Introduction")
sec.heading("Welcome", level=2)
sec.paragraph("Hello from **ANDF**! This is *important*.")
sec.callout("Remember to save your work!", variant="tip", title="Tip")
sec.table(
    headers=["Name", "Score"],
    rows=[["Alice", "95"], ["Bob", "87"]],
    caption="Table 1: Results",
)
sec.code("print('hello world')", language="python")

doc.save("report.andf")
doc.open_in_browser("report.andf")  # opens in browser

Installation

pip install andf

For development (after cloning the repo):

pip install -e .

CLI

# Create a blank document
andf new output.andf

# Open in browser
andf open output.andf

# Extract embedded JSON
andf parse output.andf --pretty

# Validate format
andf validate output.andf

# Show metadata
andf info output.andf

# AI layer summary
andf ai output.andf

File Format

An .andf file is an HTML file. The complete document data is embedded as JSON:

<script type="application/andf+json">
{
  "andf_version": "1.0",
  "document_id": "...",
  "metadata": { "title": "...", "authors": [...] },
  "sections": [...],
  "blocks": { "blk_xxx": { "type": "paragraph", "text": "..." } },
  ...
}
</script>

AI tools extract it with a single regex:

import re, json

pattern = re.compile(
    r'<script[^>]+type=["\']application/andf\+json["\'][^>]*>(.*?)</script>',
    re.DOTALL
)
data = json.loads(pattern.search(open("file.andf").read()).group(1))

Block Types

Type Description
heading Section heading (levels 1–6)
paragraph Body text with **bold**, *italic*, `code`, [ref] markup
image Embedded image from assets
table Data table with headers and rows
list Ordered or unordered list with nesting
code Syntax-highlighted code block
quote Block quote with optional attribution
callout Highlighted box: info / warning / error / success / tip
separator Horizontal rule
pagebreak Explicit page break

Themes

doc.set_theme("default")    # Inter sans-serif, clean
doc.set_theme("academic")   # Georgia serif, formal
doc.set_theme("corporate")  # Arial, business blue headings
doc.set_theme("minimal")    # System UI, minimal color

AI Layer

from andf import ANDFDocument, ANDFAILayer

doc = ANDFDocument.from_file("report.andf")
layer = ANDFAILayer(doc)

# Plain text
text = layer.full_text()

# Markdown (best for LLM input)
md = layer.to_markdown()

# RAG chunks
chunks = layer.context_chunks(max_chars=4000)

# Document summary
summary = layer.document_summary()
print(summary["key_points"])

# High-importance blocks
important = layer.blocks_by_importance(min_importance=4)

Project Structure

andf/
├── __init__.py     # Public API
├── document.py     # ANDFDocument model + fluent builder
├── renderer.py     # HTML renderer
├── parser.py       # Parser + validator
├── ai_layer.py     # AI extraction layer
└── cli.py          # Command-line interface

spec/
└── ANDF-1.0.md     # Format specification

examples/
├── create_examples.py
├── research_paper.andf
├── business_report.andf
├── legal_contract.andf
└── technical_manual.andf

tests/
└── test_andf.py

Generate Examples

python examples/create_examples.py

Opens each .andf file in your browser to see the viewer.


Run Tests

python -m pytest tests/ -v

Specification

See spec/ANDF-1.0.md for the complete format specification.


License

Apache 2.0

Metadata

Release files for andf 1.0.3

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

Source distribution (sdist)

Source distribution for andf 1.0.3
File Size Uploaded Provenance
andf-1.0.3.tar.gz 29.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 55.5 kB

Release files / andf-1.0.3.tar.gz

Download URL andf-1.0.3.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9288198257ee87746a8f5c68116d1d4b342ecf182f6a379748d311477b510c73
BLAKE2b-256 checksum
How to use checksums
632c155043b54b02c763bcec4d8fcc04ff190798a45958b889f89c07ea8da003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / andf-1.0.3-py3-none-any.whl

Download URL andf-1.0.3-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9783e77c2a21bc1de967ab997dcdd2b53d874329333df6ddcc0e6d86825ba6d3
BLAKE2b-256 checksum
How to use checksums
b4784f42699340fe05f85758420701f6385192520e3a6a71eaf99f946c442362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for andf 1.0.3

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.

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