EPUB Optimizer is a utility developed in Node.js to optimize EPUB files by compressing HTML and CSS, optimizing and reconverting images, and recompressing the EPUB file while respecting the specification and compatibility with e-readers.
Overview and advantages: Drastically reduces the size of e-books while maintaining full compatibility with Kindle, Apple Books, and other readers. The optimization is intelligent and preserves visual quality, supports modern and legacy EPUB formats, and can run without complex installations thanks to a Docker alternative.
Main features: Minification of HTML and XHTML, optimization and combination of CSS, compression and conversion of PNG images to JPEG for images without transparency, support for WebP and AVIF when appropriate, font subsetting to reduce their size, SVG optimization with SVGO, optional resizing of large images, lazy loading for images in EPUB3, JavaScript minification, and recomposition of the EPUB file with compatible ZIP packaging.
Compatibility and validation: Detects OPS and OEBPS directories, performs validation with EPUBCheck to ensure specification compliance, and applies automatic fixes to common XML and XHTML issues through modular scripts that allow customizing the process.
Recommended workflow: Export from the usual layout tool, include cover and reflowable table of contents, run the optimization, and validate the result in readers such as Apple Books and Kindle Previewer. In many cases, the size reduction is typically between 70 and 90 percent, depending on the original content.
Runtime options: Traditional installation based on Node.js and pnpm is offered, or a ready-to-use Docker container that includes all dependencies and EPUBCheck. Simplified usage examples indicate compilation and optimization commands integrated into the project scripts to run the tool and clean up temporary files.
Installation and requirements: For traditional installation, Node.js 14 or higher, Java JRE 1.7 or higher for EPUBCheck, and pnpm or npm are recommended. Alternatively, Docker can be used to avoid installing local dependencies and ensure a reproducible environment on Windows, Mac, and Linux.
Modular customization: The project includes modular scripts for general fixes and structural modifications such as adding the cover to the table of contents, updating the summary page, or adjusting navigation. Each fix can be easily enabled or disabled to tailor the optimization to specific needs.
Development and testing: Built in TypeScript with a clear separation between source and compiled code, the build process generates an optimized dist. The codebase includes automated tests with Vitest, linting and formatting with Prettier, and a workflow for safe minification with Terser.
Common errors and solutions: Quick checks are described for frequent issues such as docker commands not found, file permissions, errors with EPUBCheck, or incorrect input/output paths. It is recommended to review the issues section in the repository if any problem arises.
Why choose this tool: Ideal for publishers and authors who need to optimize e-book catalogs while maintaining quality and compatibility, and for publishing workflows where file size and EPUB validity are critical.
About Q2BSTUDIO: Q2BSTUDIO is a software development company specialized in creating custom applications and bespoke software for clients across various sectors. We are experts in artificial intelligence and offer AI solutions for businesses that include custom AI agents, automation, and analytics. We also provide cybersecurity services to protect infrastructures and data, as well as AWS and Azure cloud services to deploy scalable and secure applications.
Our business intelligence services include integration and visualization with Power BI, creation of data pipelines, and reporting models to make data-driven decisions. We implement business intelligence service solutions oriented toward results and measuring business impact.
Custom solutions and consulting: At Q2BSTUDIO, we design and implement custom applications that integrate artificial intelligence, machine learning, and AI agent capabilities, optimizing processes and improving user experience. We also offer audits and cybersecurity services, system hardening, identity and access management, and penetration testing.
Cloud integration and deployment: We offer managed deployments on AWS and Azure cloud services, serverless architectures, containers, and CI/CD pipelines. Our approach facilitates scalability, resilience, and reduced operational costs, also integrating monitoring and observability tools.
Benefits of working with Q2BSTUDIO: Access to a multidisciplinary team with experience in development, artificial intelligence, cybersecurity, and cloud. We deliver turnkey solutions and collaborate with clients to transform ideas into robust and scalable products. We are creative and results-oriented, optimizing both technical processes and business return on investment.
Keywords for positioning: custom applications, bespoke software, artificial intelligence, cybersecurity, AWS and Azure cloud services, business intelligence services, AI for businesses, AI agents, Power BI.
Contact and next step: If you wish to optimize your EPUB catalog, integrate artificial intelligence capabilities, or develop secure and scalable custom applications in the cloud, contact Q2BSTUDIO for an initial consultation and a proposal tailored to your needs.
License and contribution: The base project is published under the MIT license and accepts contributions and bug reports in its repository. For corporate integrations and professional support, Q2BSTUDIO offers consulting, customization, and ongoing support services.


