DEV Community

Cover image for Building a Free Markdown to PDF Converter (No Sign-ups, 100% Browser-Based)
BlinkNBuild
BlinkNBuild

Posted on

Building a Free Markdown to PDF Converter (No Sign-ups, 100% Browser-Based)

The Problem

I was constantly frustrated with existing markdown to PDF converters. Most of them:

  • Required sign-ups and accounts
  • Had paywalls or subscription fees
  • Uploaded your files to their servers (privacy concerns)
  • Had clunky interfaces
  • Broke formatting on code blocks or math equations

I just wanted something simple that worked in my browser without jumping through hoops. So I decided to build my own.

What I Built

A completely free, browser-based markdown to PDF converter that runs 100% client-side. No servers, no data collection, no sign-ups required.

Try it here: https://free-markdown-to-pdf.netlify.app/

GitHub: https://github.com/S-SUJAN-S/free-markdown-to-pdf

Key Features

  • Live Preview - See your formatted content as you type
  • Syntax Highlighting - Code blocks look professional with Highlight.js
  • Math Equations - LaTeX math rendering using KaTeX
  • Multiple Themes - Dark mode, light mode, and high contrast
  • Customization - Adjust fonts, spacing, margins to your liking
  • Privacy First - Everything runs in your browser, zero data collection
  • No Installation - Just open the URL and start using it

Tech Stack

I kept it simple and used:

  • React (loaded via CDN)
  • Babel Standalone (for in-browser JSX compilation)
  • Marked.js (markdown parsing)
  • Highlight.js (syntax highlighting for code)
  • KaTeX (LaTeX math rendering)
  • Google Fonts (Fraunces, DM Sans, JetBrains Mono)

The entire thing is a single HTML file - no complex build process, no npm dependencies to install locally. Just clone and open!

How It Works

The workflow is super simple:

  1. Paste your markdown content
  2. See it formatted in real-time
  3. Customize if needed (fonts, themes, spacing)
  4. Use your browser's print function to save as PDF

Since everything runs client-side, your content never leaves your browser. I literally cannot see what you're converting even if I wanted to.

Why a Single HTML File?

I wanted this to be as accessible as possible. Anyone should be able to:

  • Clone the repo and open index.html
  • Host it anywhere (GitHub Pages, Netlify, their own server)
  • Modify it without needing to understand webpack or build tools
  • Use it offline once the page loads

Plus, it makes the code easy to read and understand for beginners.

Use Cases

I built this originally to save formatted conversations and notes, but people can use it for:

  • Converting documentation
  • Creating PDFs from markdown notes
  • Formatting research papers
  • Saving formatted conversations from AI tools
  • Quick markdown previewing
  • Any markdown → PDF needs

Challenges I Faced

1. Math Rendering

Getting KaTeX to work properly with various LaTeX syntax was tricky. I had to handle both inline math ($...$) and display math ($$...$$) correctly.

2. Print Styling

Making sure the PDF output looked exactly like the preview required a lot of CSS tweaking with @media print queries.

3. Theme Switching

Implementing multiple themes while maintaining consistency across all UI elements took more work than expected.

4. Code Block Formatting

Ensuring code blocks looked good in both the preview and the final PDF required careful styling.

What's Next?

I'm thinking about adding:

  • Export to Word/HTML formats
  • Preset templates for different document types
  • Batch conversion (multiple files at once)
  • More theme options
  • Table of contents generation
  • Custom CSS injection

What features would you find useful? Let me know in the comments!

Open Source

The project is fully open source with an MIT license. Feel free to:

  • Use it for any purpose
  • Fork it and make your own version
  • Submit PRs for improvements
  • Report bugs or request features

Links:

Try It Out!

I'd love to hear your feedback. If you find it useful, give it a star on GitHub! And if you find bugs or have feature suggestions, open an issue.

Happy converting! 🚀


Have you built any side projects to solve your own problems? Share them in the comments!

Top comments (2)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.