Documentation
Learn how L0ss compresses different file types and what each compression level does.
Compression Levels
L0ss offers three compression levels, each with different tradeoffs between file size reduction and data preservation.
Minimal - Safe Optimizations
Recommended for: Production files where accuracy is critical
Typical reduction: 10-30%
Data loss: Low - Removes only redundant data (whitespace, comments, metadata)
Reversibility: Often 100% recoverable to original structure
- Removes whitespace and formatting
- Strips comments and documentation
- Removes unnecessary metadata
- Preserves all functional data
Moderate - Balanced Approach
Recommended for: Most use cases - best balance of size and quality
Typical reduction: 30-60%
Data loss: Medium - Removes non-critical data and applies smart optimizations
Reversibility: Partially recoverable (core data intact)
- All minimal optimizations
- Removes low-priority fields
- Rounds numbers to reasonable precision
- Deduplicates similar values
- Simplifies nested structures
Aggressive - Maximum Compression
Recommended for: Testing, prototypes, or when size is paramount
Typical reduction: 60-90%
Data loss: High - Keeps only essential data
Reversibility: Limited (skeleton structure only)
- All moderate optimizations
- Aggressive field removal
- Heavy numeric rounding
- Significant data sampling
- Schema simplification
File Type Compression Methods
JSON Files
JSON compression focuses on removing verbosity while maintaining structure.
Minimal Level:
- Remove whitespace and indentation
- Strip null values (configurable)
- Remove empty arrays/objects
Moderate Level:
- All minimal optimizations
- Remove optional fields (description, metadata, etc.)
- Round numbers to 2 decimal places
- Deduplicate repeated objects
- Shorten long string values
Aggressive Level:
- All moderate optimizations
- Keep only critical fields (id, name, core data)
- Round to integers where possible
- Sample large arrays (keep every nth item)
- Replace verbose values with abbreviations
Example:
// Original (428 bytes)
{
"users": [
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"bio": "Software engineer with 10 years experience...",
"score": 87.6543,
"metadata": {
"created": "2023-01-15",
"updated": "2024-01-15"
}
}
]
}
// Moderate (156 bytes, 64% reduction)
{"users":[{"id":1,"name":"John Doe","email":"john@example.com","score":87.65}]}
CSV Files
CSV compression removes unnecessary columns and rows while preserving data structure.
Minimal Level:
- Remove empty rows and columns
- Trim whitespace from cells
- Remove duplicate rows
Moderate Level:
- All minimal optimizations
- Remove low-variance columns (all same value)
- Round numeric values
- Truncate long text fields
Aggressive Level:
- All moderate optimizations
- Keep only first N columns
- Sample rows (every nth row)
- Remove non-essential columns entirely
JavaScript Files
JavaScript compression focuses on minification and code reduction.
Minimal Level:
- Remove comments and docstrings
- Remove whitespace and newlines
- Preserve all functional code
Moderate Level:
- All minimal optimizations
- Shorten variable names
- Remove console.log statements
- Simplify expressions
Aggressive Level:
- All moderate optimizations
- Remove debug code and assertions
- Inline small functions
- Remove error handling (try/catch)
HTML/CSS Files
Web file compression removes formatting and optional elements.
Minimal Level:
- Remove comments and whitespace
- Remove optional closing tags
- Minify inline CSS/JS
Moderate Level:
- All minimal optimizations
- Remove data attributes
- Shorten color codes (#ffffff → #fff)
- Remove unused CSS rules
Aggressive Level:
- All moderate optimizations
- Remove accessibility attributes
- Strip meta tags
- Inline critical CSS only
SQL Files
SQL compression focuses on query optimization and formatting removal.
Minimal Level:
- Remove comments and whitespace
- Remove formatting and indentation
- Preserve all queries
Moderate Level:
- All minimal optimizations
- Shorten table/column aliases
- Remove optional keywords
- Combine related statements
Aggressive Level:
- All moderate optimizations
- Remove CREATE/DROP statements
- Keep only INSERT/UPDATE/SELECT
- Sample large data sets
XML/YAML Files
Structured data compression removes verbosity and optional elements.
Minimal Level:
- Remove whitespace and formatting
- Remove comments
- Remove optional attributes
Moderate Level:
- All minimal optimizations
- Remove namespace declarations
- Shorten element names
- Remove metadata elements
Aggressive Level:
- All moderate optimizations
- Keep only core data elements
- Flatten nested structures
- Convert to minimal schema
Recovery Manifests
Every compression generates a recovery manifest that documents what changes were made. This manifest allows you to understand exactly what was removed or modified.
Manifest Contents:
- Operations Applied: List of all transformations
- Original Hash: Verify file integrity
- Compression Stats: Before/after sizes, reduction percentage
- Reversibility Score: How much can be recovered
- Field Mapping: Which fields were removed or modified
Using Manifests:
// Download your manifest
GET /api/manifest/:manifestId
// Response includes recovery information
{
"operations": [
{"type": "remove_whitespace", "reversible": true},
{"type": "remove_field", "field": "metadata", "reversible": false},
{"type": "round_numbers", "precision": 2, "reversible": false}
],
"reversibility": "Partially recoverable"
}
Best Practices
Choosing a Compression Level:
Use Case | Recommended Level | Reason |
---|---|---|
Production backups | Minimal | Preserve all functional data |
Development datasets | Moderate | Good balance for testing |
Prototypes/demos | Aggressive | Size matters more than accuracy |
Transfer large logs | Moderate | Keep essential info, reduce size |
Archive old data | Minimal | Future recovery may be needed |
Tips for Maximum Compression:
- Remove unnecessary fields first: Clean your data before uploading
- Use appropriate file types: JSON compresses better than XML
- Deduplicate before compression: Remove duplicate entries first
- Download the manifest: Always save recovery information
- Test with samples: Try different levels on a subset first
API Reference
For programmatic access, see the API Endpoints section on the homepage.