Cut LLM costs and boost processing speed by transforming verbose HTML into efficient Emmet notation
Project description
Emmetify 🚀
Cut your LLM processing costs by up to 90% by transforming verbose HTML into efficient Emmet notation, without losing structural integrity.
Why Emmetify? 🤔
- 💰 Drastically Reduce Costs - Process HTML with your LLM agents at a fraction of the cost by using our efficient Emmet-based compression
- 🎯 Maintain Performance - Your LLM agents can still generate XPath and CSS selectors with the same accuracy using the compressed format
- 🔌 Seamless Integration - Emmet syntax is well-understood by all major LLMs thanks to its 10+ years of widespread use in frontend development
- ⚡ Fast Processing - Less tokens means faster processing times for your HTML analysis tasks
How It Works 🛠️
Emmetify converts complex HTML structures into concise Emmet notation. For example:
<div class="container">
<header class="header">
<nav class="nav">
<ul class="nav-list">
<li class="nav-item"><a href="#">Link</a></li>
</ul>
</nav>
</header>
</div>
Becomes:
div.container>header.header>nav.nav>ul.nav-list>li.nav-item>a[href=#]{Link}
Using the OpenAI Tokenizer, we can see this simple transformation reduces token count from:
- HTML: 59 tokens
- Emmet: 22 tokens
That's 63% fewer tokens while preserving all structural information! And this is just with default settings.
You can achieve even higher compression rates (up to 90%, or even more depending on the HTML structure) by using advanced configuration options:
- Removing unnecessary tags
- Simplifying attributes
- Optimizing class names
- Shortening URLs
Check our documentation for detailed optimization strategies and their impact on token reduction.
Why Not Just Use Markdown? 🤔
While Markdown is great for content representation, it removes HTML structure that's crucial for web automation. When working with tools like Selenium or Playwright, you need the actual DOM structure to click buttons, fill forms, and follow links. Emmetify gives you the best of both worlds:
- Preserves complete HTML structure for accurate element targeting
- Uses fewer tokens than raw HTML (up to 90% reduction)
- Allows LLMs to make informed decisions about page navigation and interaction
Perfect for scenarios where you need both efficiency and structural fidelity!
The Technology Behind It 🔍
Emmetify leverages Emmet notation - a powerful and mature syntax that's been a standard in web development for over a decade. While developers typically use Emmet to expand short abbreviations into HTML:
div.container>h1{Title}+p{Content}
↓ Expands to ↓
<div class="container">
<h1>Title</h1>
<p>Content</p>
</div>
Emmetify uses this well-established syntax in reverse, converting verbose HTML back into this concise format that LLMs can understand just as well as raw HTML.
Installation 🔧
pip install emmetify
Usage 💻
Basic Usage
from emmetify import Emmetifier
import requests
emmetifier = Emmetifier()
html = requests.get("https://example.com").text
emmet = emmetifier.emmetify(html)
print(emmet)
Advanced HTML Simplification ⚡
Transform verbose HTML into its most essential form while preserving navigational structure. This mode intelligently:
- Skips non-essential HTML tags
- Prioritizes important attributes
- Removes redundant information
For example, this verbose HTML:
<link rel="stylesheet" href="style.css">
<div id="main" class="container" style="color: red;" data-test="ignore">Example</div>
Becomes this concise Emmet notation:
div#main.container{Example}
Much shorter, yet retains all necessary information for LLM navigation and processing!
Advanced Usage:
from emmetify import Emmetifier, emmetify_compact_html
import requests
# Fetch and process HTML
html = requests.get("https://example.com").text
# Configure Emmetifier class
emmetifier = Emmetifier(config={
"html": {
"skip_tags": True,
"prioritize_attributes": True
}
})
emmetified = emmetifier.emmetify(html)
print(emmetified)
# or use the shorthand function, which is a shortcut for emmetifier.emmetify(html)
# with the default configuration for compact HTML
emmetified = emmetify_compact_html(html)
print(emmetified)
Examples
See the examples directory for more examples of how to use Emmetify.
Backlog 📝
- Add support for HTML
- Add examples
Supported Formats 📊
- ✅ HTML
- 🚧 XML (Coming Soon)
- 🚧 JSON (Coming Soon)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emmetify-0.1.0.tar.gz.
File metadata
- Download URL: emmetify-0.1.0.tar.gz
- Upload date:
- Size: 51.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee330d5b3c8fd133db3d3cd033ae48d2ac51c8c953cf75fe999394a085873a10
|
|
| MD5 |
8ec99b0675f19a2f343a11be420626fd
|
|
| BLAKE2b-256 |
2ca6bcefbb776d87d7fd1827ee2cb05ec472801ae1af9ed6c1e7bc14f5e5901c
|
Provenance
The following attestation bundles were made for emmetify-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on emmetify/emmetify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emmetify-0.1.0.tar.gz -
Subject digest:
ee330d5b3c8fd133db3d3cd033ae48d2ac51c8c953cf75fe999394a085873a10 - Sigstore transparency entry: 165950731
- Sigstore integration time:
-
Permalink:
emmetify/emmetify-py@cc04673d011ed02aeb72cb55b7467387a5b379fb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/emmetify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@cc04673d011ed02aeb72cb55b7467387a5b379fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file emmetify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: emmetify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 54.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91fbe4123d06b0b8fe2bcce19dd5d59bd24495cd920eae35a13c14be991950b2
|
|
| MD5 |
d72c8bc75807921ee0b555c16f578143
|
|
| BLAKE2b-256 |
b04d97005136315822f097f1e32aa9f1cc3c078e4dec200a2b1aa0fd3242c13a
|
Provenance
The following attestation bundles were made for emmetify-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on emmetify/emmetify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emmetify-0.1.0-py3-none-any.whl -
Subject digest:
91fbe4123d06b0b8fe2bcce19dd5d59bd24495cd920eae35a13c14be991950b2 - Sigstore transparency entry: 165950732
- Sigstore integration time:
-
Permalink:
emmetify/emmetify-py@cc04673d011ed02aeb72cb55b7467387a5b379fb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/emmetify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@cc04673d011ed02aeb72cb55b7467387a5b379fb -
Trigger Event:
release
-
Statement type: