npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

emmetify-js

v0.1.0

Published

Reduce token usage by 60% and optimize LLM interactions by converting HTML, JSON, and XML to compact Emmet-like syntax

Readme

Emmetify JS

JavaScript implementation of the Emmetify library - reduces token usage and optimizes LLM interactions by converting HTML, JSON, and XML to compact Emmet-like syntax.

🚀 Token Reduction Statistics

┌─────────────────────────────────────────────────────────────┐
│                   TOKEN USAGE COMPARISON                    │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│   Before Emmetify:  ████████████████████████████████  100%  │
│                                                             │
│   After Emmetify:   ██████████████                    40%   │
│                                                             │
│                     ▼ 60% REDUCTION IN TOKENS              │
└─────────────────────────────────────────────────────────────┘

💰 Cost Savings Calculator

Real-World Example: E-commerce Product Page

┌──────────────────────────────────────────────────────────────────┐
│ Original HTML Size: 12,450 characters                           │
│ Emmetified Size:     4,980 characters (~60% reduction)          │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│ 📈 Token Count:                                                  │
│    • Before: ~3,112 tokens                                      │
│    • After:  ~1,245 tokens                                      │
│                                                                  │
│ 💵 Cost per Million Tokens (GPT-4):                             │
│    • Input: $30.00                                              │
│                                                                  │
│ 💡 Savings per Million Requests:                                │
│    • Before: $93.36                                             │
│    • After:  $37.35                                             │
│    • SAVED:  $56.01 (60% reduction!)                            │
│                                                                  │
│ 🏢 Enterprise Scale (100M requests/month):                      │
│    • Monthly Savings: $5,601                                    │
│    • Annual Savings:  $67,212                                   │
└──────────────────────────────────────────────────────────────────┘

📊 Format-Specific Compression Rates

┌────────────────────────────────────────────────────┐
│              COMPRESSION BY FORMAT                 │
├────────────────────────────────────────────────────┤
│                                                    │
│  HTML:  ████████████████░░░░░░░░░░░░░░  65% 🔥    │
│  JSON:  ██████████████░░░░░░░░░░░░░░░░  58% 💪    │
│  XML:   ████████████████░░░░░░░░░░░░░░  62% ⚡    │
│                                                    │
└────────────────────────────────────────────────────┘

Installation

npm install

Usage

HTML Conversion

import { emmetifyHtml, emmetifyCompactHtml } from './src/index.js';

// Basic usage
const html = '<div class="container"><p>Hello World</p></div>';
const result = emmetifyHtml(html);
console.log(result.result); // div.container>p{Hello World}

// Compact version with optimizations
const compactResult = emmetifyCompactHtml(html);
console.log(compactResult.result);

JSON Conversion

import { emmetifyJson, emmetifyCompactJson } from './src/index.js';

const json = JSON.stringify({ user: { name: 'John', age: 30 } });
const result = emmetifyJson(json);
console.log(result.result); // obj>prop[user]>obj>prop[name]>str{John}+prop[age]>num{30}

// Compact version with token optimization
const compactResult = emmetifyCompactJson(json);
console.log(compactResult.maps.keys); // Simplified keys mapping

XML Conversion

import { emmetifyXml, emmetifyCompactXml } from './src/index.js';

const xml = '<book id="1"><title>Sample</title></book>';
const result = emmetifyXml(xml);
console.log(result.result); // book#1>title{Sample}

// Compact version with namespace simplification
const compactResult = emmetifyCompactXml(xml);

API

HTML Functions

  • emmetifyHtml(content, format, options) - Convert HTML to Emmet notation
  • emmetifyCompactHtml(content) - Convert HTML with compact optimizations

JSON Functions

  • emmetifyJson(content, options) - Convert JSON to Emmet-like notation
  • emmetifyCompactJson(content) - Convert JSON with key/value optimization

XML Functions

  • emmetifyXml(content, options) - Convert XML to Emmet notation
  • emmetifyCompactXml(content) - Convert XML with namespace optimization

Configuration Options

{
  debug: false,
  indent: false,
  indentSize: 2,
  html: {
    skipTags: false,
    prioritizeAttributes: false,
    simplifyClasses: false,
    simplifyImages: false,
    simplifyAbsoluteLinks: false,
    simplifyRelativeLinks: false,
    skipEmptyAttributes: false,
    tagsToSkip: ['script', 'style', 'noscript', 'head', 'meta', 'link', 'title', 'base', 'svg'],
    attributesPriority: {
      primaryAttrs: ['id', 'class', 'href', 'role', 'aria-label', 'title'],
      secondaryAttrs: ['name', 'type', 'value', 'placeholder', 'alt', 'for'],
      ignoreAttrs: ['style', 'target', 'rel', 'loading', 'srcset', 'sizes', 'width', 'height']
    }
  },
  json: {
    simplifyKeys: false,
    simplifyLongStrings: false,
    stringLengthThreshold: 20,
    compactArrays: false,
    compactObjects: false
  },
  xml: {
    simplifyNamespaces: false,
    simplifyLongAttributes: false,
    skipComments: false,
    skipTags: false,
    preserveCData: true,
    tagsToSkip: ['xsl:stylesheet', 'xsl:template', 'xs:schema']
  }
}

License

MIT