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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xbibzlibrary/base64

v1.0.3

Published

Base64 Encoding/Decoding Library with File Preview Support

Readme

🚀 Base64 Tools

Advanced Base64 Encoding Library with File Preview Support

Version License CDN Status

Transform any file into base64 with style

FeaturesQuick StartDocumentationDemoSupport

hi xbibz slow


🎯 What Makes This Special?

This isn't just another base64 library. Built with modern JavaScript, it delivers professional-grade encoding and decoding with an elegant API that developers actually enjoy using.

// That's all it takes
const base64 = new XbibzBase64();
const result = await base64.encodeFile(yourFile);
console.log(result.dataURI); // Ready to use!

✨ Features

🎨 Multi-Format Support

Handle images, videos, audio, archives, and virtually any file type with intelligent MIME detection and validation.

📦 Batch Processing

Process multiple files simultaneously with a sophisticated queue system that maintains performance and reliability.

🔍 Visual Previews

Generate real-time previews for images, videos, and audio with comprehensive metadata extraction.

Performance First

Optimized for speed with built-in monitoring, intelligent caching, and efficient memory management.

🛡️ Error Resilience

Comprehensive error handling with detailed logging and graceful fallbacks for edge cases.

🌐 Universal Compatibility

Works seamlessly across all modern browsers with zero dependencies.

📊 Smart Analytics

Built-in performance monitoring and detailed statistics for optimization insights.

🎁 Production Ready

Battle-tested code with thorough validation and professional-grade reliability.

🚀 Quick Start

Installation via CDN

<script src="https://cdn.jsdelivr.net/npm/@xbibzlibrary/[email protected]/base64.js"></script>

Basic Usage

// Initialize the library
const base64 = new XbibzBase64();

// Encode a single file
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async (e) => {
    const file = e.target.files[0];
    const result = await base64.encodeFile(file);
    
    console.log('Encoded successfully!');
    console.log('Data URI:', result.dataURI);
    console.log('Base64 String:', result.base64String);
    console.log('File Info:', result.fileName, result.fileSize);
});

// Decode base64 back to file
const decoded = base64.decodeBase64(result.dataURI);
console.log('Original file restored!', decoded.blob);

📖 Documentation

Core Methods

encodeFile(file)

Encode a single file to base64 format.

const result = await base64.encodeFile(file);
// Returns: {
//   dataURI: "data:image/png;base64,iVBOR...",
//   base64String: "iVBOR...",
//   fileName: "image.png",
//   mimeType: "image/png",
//   fileSize: 45632,
//   encodedSize: 60844
// }

encodeFiles(files)

Encode multiple files with progress tracking.

const results = await base64.encodeFiles([file1, file2, file3]);
// Returns array of encoded file objects

decodeBase64(base64String, mimeType, fileName)

Decode base64 string back to file.

const result = base64.decodeBase64(
    "data:image/png;base64,iVBOR...",
    null, // Auto-detect
    "decoded_image.png"
);
// Returns: { blob, fileName, mimeType, fileSize }

addToQueue(files)

Add files to processing queue.

await base64.addToQueue([file1, file2, file3]);
const status = base64.getQueueStatus();

processQueue()

Process all queued files.

const results = await base64.processQueue();
console.log(`${results.successfulCount} files processed`);

Utility Methods

// Get library information
const info = base64.getLibraryInfo();

// Get queue status
const status = base64.getQueueStatus();

// Access logger
const logger = base64.getLogger();
logger.log('info', 'Custom log message');

// Clear queue
const cleared = base64.clearQueue();

🎨 Supported File Types

🖼️ Images

JPEG • PNG • GIF • WebP BMP • SVG • ICO • TIFF

🎬 Videos

MP4 • WebM • OGG AVI • MOV • WMV • FLV

🎵 Audio

MP3 • WAV • OGG AAC • FLAC • M4A • WMA

📦 Archives

ZIP • RAR • 7Z TAR • GZIP • BZ2

Plus support for documents (PDF, DOC, XLS), text files, and virtually any file format.

🎮 Live Demo

Experience the library in action with our interactive demo page featuring:

  • 🎯 Drag & drop file upload
  • 📊 Real-time processing statistics
  • 🖼️ Visual file previews
  • 📝 Activity logging
  • ⚡ Queue management
  • 📥 Download encoded files

View Live Demo (Replace with your actual demo URL)

💡 Advanced Examples

Batch Processing with Progress

const files = Array.from(fileInput.files);

// Add to queue
await base64.addToQueue(files);

// Monitor queue
const status = base64.getQueueStatus();
console.log(`Queue size: ${status.queueSize}`);

// Process with results
const results = await base64.processQueue();
results.successful.forEach(file => {
    console.log(`✓ ${file.fileName} encoded successfully`);
});

Image Preview Generation

const imageFile = document.querySelector('input[type="file"]').files[0];
const encoded = await base64.encodeFile(imageFile);

// Create instant preview
const img = document.createElement('img');
img.src = encoded.dataURI;
document.body.appendChild(img);

Error Handling

try {
    const result = await base64.encodeFile(file);
    console.log('Success:', result);
} catch (error) {
    console.error('Encoding failed:', error.message);
    
    // Access detailed logs
    const logs = base64.getLogger().getLogs();
    logs.filter(log => log.level === 'error').forEach(log => {
        console.error(log.message);
    });
}

🔧 Configuration

The library supports configuration through constructor options:

const base64 = new XbibzBase64({
    maxFileSize: 50 * 1024 * 1024, // 50MB limit
    enableLogging: true,
    autoProcess: false
});

📊 Performance

Optimized for speed and efficiency:

  • Fast encoding using native browser APIs
  • 💾 Memory efficient with chunked processing for large files
  • 🔄 Async operations preventing UI blocking
  • 📈 Scalable queue system for batch operations

🛠️ Browser Support

Works on all modern browsers:

  • ✅ Chrome 90+
  • ✅ Firefox 88+
  • ✅ Safari 14+
  • ✅ Edge 90+
  • ✅ Opera 76+

📦 File Size

  • Minified: ~12KB
  • Gzipped: ~4KB
  • Zero dependencies

🤝 Contributing

We welcome contributions! Feel free to:

  • 🐛 Report bugs
  • 💡 Suggest features
  • 📝 Improve documentation
  • 🔧 Submit pull requests

📄 License

MIT License - feel free to use in personal and commercial projects.

👨‍💻 Author

Xbibz Official

  • memek
  • TikTok
  • Buying me a coffee

🌟 Support

If you find this library helpful, consider:

  • ⭐ Starring the repository
  • 📢 Sharing with others
  • Buying me a coffee

Made with ❤️ by Xbibz Official

DocumentationReport BugRequest Feature