Home › Developer Tools › Base64 to PDF

Base64 to PDF

Paste a Base64-encoded PDF, with or without the data:application/pdf;base64, prefix, to check it, preview every page and download it as a .pdf file. Switch tabs to turn a PDF into a Base64 string. Everything is decoded locally in your browser.

Last updated:

0 characters
The PDF preview appears here.
Advertisement
Advertisement

How to use the Base64 to PDF

  1. Paste the Base64 string into the box (it may start with JVBER or data:application/pdf;base64,). A sample is loaded so you can see how it works.
  2. Read the check under the box: it confirms a valid PDF and shows its version, size and page count, or explains what is wrong.
  3. Look at the preview to make sure it is the document you expect.
  4. Set a file name and press Download PDF to save it, or Open in new tab to use your browser's PDF viewer.
  5. Need the reverse? Open the PDF → Base64 tab, drop a PDF and copy or download its Base64 string.

Recognising file types from their Base64 start

The first characters of a Base64 string reveal the file type, because they encode the file's "magic bytes". Use this table to check what you have before converting.

Base64 starts withDecoded bytesFile type
JVBERi0%PDF-PDF document
iVBORw0KGgo\x89PNG\r\n\x1a\nPNG image
/9j/\xFF\xD8\xFFJPEG image
R0lGODGIF8GIF image
UEsDBBPK\x03\x04ZIP, DOCX, XLSX, PPTX
SlZCRVJpJVBERiA PDF encoded twice

Decode a Base64 PDF in code

EnvironmentCode
Linux / macOS shellbase64 -d input.txt > output.pdf (macOS: base64 -D -i input.txt -o output.pdf)
Windows PowerShell[IO.File]::WriteAllBytes("out.pdf", [Convert]::FromBase64String((Get-Content in.txt -Raw)))
Pythonopen("out.pdf", "wb").write(base64.b64decode(s))
JavaScript (browser)await (await fetch("data:application/pdf;base64," + s)).blob()
Node.jsfs.writeFileSync("out.pdf", Buffer.from(s, "base64"))
JavaFiles.write(Path.of("out.pdf"), Base64.getMimeDecoder().decode(s))

Where Base64 PDFs come from

JSON APIs cannot carry raw binary, so services that generate invoices, shipping labels, signed contracts or reports often return the PDF as a Base64 string inside a JSON field. Email attachments are also Base64 inside the MIME message, wrapped at 76 characters per line. When you need to test such an API, paste the whole JSON response here: the tool finds the field that holds the PDF.

Frequently asked questions

How do I convert Base64 to PDF?

Paste the Base64 text into the box. The tool removes any data URI prefix, quotes or line breaks, decodes the bytes, checks for the %PDF header and shows a preview. Press Download PDF to save the decoded file. The conversion happens in your browser, so the document is never uploaded.

How can I tell if a Base64 string is a PDF?

A PDF always begins with the bytes %PDF-, which encode to the Base64 characters JVBERi0. If your string starts with JVBER it is almost certainly a PDF. Images start differently: PNG with iVBORw0KGgo and JPEG with /9j/. This tool also names the real file type when the data is not a PDF.

Why does my Base64 PDF not open?

The most common causes are a string that was cut off when copied (the PDF has no %%EOF at the end), extra characters such as quotes or escaped \n sequences, a missing or wrong prefix, or data that was Base64-encoded twice. The checker reports each of these, and it removes quotes, escapes, whitespace and prefixes automatically.

What is data:application/pdf;base64?

It is a data URI prefix that tells a browser the following Base64 text is a PDF file. APIs and web apps often return PDFs in this form so they can be embedded directly. You can paste the string with or without the prefix.

How much bigger is Base64 than the PDF?

Base64 turns every 3 bytes into 4 characters, so the text is about 33% larger than the original file, plus line breaks if it is wrapped. A 750 KB PDF becomes roughly 1 MB of Base64.

Is it safe to decode confidential PDFs here?

Yes. The Base64 is decoded with JavaScript in your own browser tab and the preview is drawn locally. No text or file is sent to a server, and closing the tab removes the data.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.PDF ViewerOpen and read PDF files in your browser with zoom, search, thumbnails and fullscreen.Password GeneratorCreate strong passwords and passphrases.Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.MD5 Hash GeneratorGenerate MD5 hashes of text, lines or files and verify checksums.SHA-256 Hash GeneratorSHA-256 and HMAC-SHA256 hashes of text, lines or files, in hex or Base64.URL Encoder DecoderPercent-encode or decode URLs, query strings and form data.HTML Entity Encoder / DecoderEscape and unescape HTML entities, named or numeric.Bcrypt Hash Generator & CheckerCreate bcrypt password hashes and check a password against a hash.Binary TranslatorConvert text to binary, hex, octal and back.HMAC GeneratorGenerate and verify HMAC signatures with SHA-256, SHA-512, SHA-1 or MD5.CRC32 Checksum CalculatorCalculate CRC-32, CRC-32C, CRC-16 and Adler-32 checksums of text or large files.JWT DecoderDecode JSON Web Tokens, read the claims and expiry, and verify HS256 signatures.JWT GeneratorCreate and sign HS256, HS384 or HS512 JSON Web Tokens in your browser and verify them.Password Strength CheckerSee how strong a password really is, how long it takes to crack and how to improve it.Caesar CipherEncode and decode Caesar shift ciphers and crack unknown shifts with a ranked brute force.Vigenère CipherEncrypt and decrypt Vigenère and Autokey ciphers, and crack unknown keys with frequency analysis.Atbash CipherEncode and decode Atbash ciphers (A↔Z, B↔Y) in Latin or Hebrew, with a live letter mapping table.ASCII TableFull ASCII code chart 0–255 in decimal, hex, octal, binary and HTML, with search and copy.Unicode Character LookupFind Unicode characters by name or code point and copy them with UTF-8, HTML and code escapes.Punycode ConverterConvert international domain names, emails and URLs between Unicode and xn-- Punycode, in bulk.JSON Escape / UnescapeEscape text for a JSON string, unescape \n and \" back to text, or stringify a whole object.Binary to HexConvert binary to hex instantly with steps and signed mode.Hex to BinaryConvert hex to binary instantly with steps and signed mode.Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Hex CalculatorHexadecimal + − × ÷ and AND, OR, XOR, NOT, shifts with decimal and binary equivalents.Base32 Encoder / DecoderEncode and decode Base32 (RFC 4648), Base32hex, Crockford and z-base-32 from text, hex or files.Base58 Encoder / DecoderEncode and decode Base58 and Base58Check (Bitcoin alphabet) from text or hex, with checksum verification.Unicode Escape / UnescapeConvert text to \uXXXX, \u{...}, \x, &#...; or CSS escapes and decode them back.File Hash CheckerGet MD5, SHA-1, SHA-256 and SHA-512 checksums of files and verify them against a hash.TOTP GeneratorGenerate 2FA one-time codes from a secret key, create otpauth QR codes and verify codes.RSA Key GeneratorGenerate 2048, 3072 or 4096-bit RSA key pairs as PEM, PKCS#1, JWK or OpenSSH, locally.SSL Certificate DecoderDecode PEM SSL/X.509 certificates: subject, issuer, expiry, SANs, key and fingerprints.Text Encryption ToolEncrypt and decrypt text with a password using AES-256-GCM, entirely in your browser.Argon2 Hash GeneratorHash passwords with Argon2id, Argon2i or Argon2d and verify them against an encoded hash.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.String Escape / UnescapeEscape or unescape strings for JavaScript, Java, C#, Python, C, SQL, regex, CSV and shell.UTF-8 Encoder / DecoderConvert text to UTF-8 bytes in hex, decimal, binary, \x or % and decode bytes back to text.UUID Decoder & ValidatorDecode any UUID: version, variant, v1/v6/v7 timestamp and MAC node, plus bulk validation.Base64 to FileDecode Base64 or a data URI to a downloadable file; detects the real file type and previews it.File Encryption ToolEncrypt and decrypt any file with a password using AES-256-GCM, entirely in your browser.Passphrase GeneratorMake strong, memorable diceware passphrases from a 7,776-word list, with entropy in bits.CSR DecoderDecode a PEM certificate signing request: subject, SANs, key size, signature and CA readiness checks.Enigma Machine SimulatorEncrypt and decrypt with a virtual Enigma I, M3 or M4: rotors, rings, plugboard and lampboard.Hex Opacity CalculatorConvert opacity percent to a 2-digit HEX alpha code and full #RRGGBBAA color, with a 0-100% table.Playfair CipherEncrypt and decrypt Playfair ciphers from a keyword, with the 5x5 key square and every digraph step.Pwned Password CheckerCheck if a password appeared in data breaches; only 5 characters of its SHA-1 hash are sent.RSA Encryption ToolEncrypt text with an RSA public key and decrypt it with the private key using RSA-OAEP in your browser.SAML DecoderDecode SAMLRequest and SAMLResponse messages to readable XML, attributes and validity times.SSL Certificate ConverterConvert SSL certificates and keys between PEM, DER, PFX/P12 and P7B in your browser.Checksum CalculatorCompute 8-bit sum, two's complement LRC, XOR/BCC, NMEA, Fletcher and Internet checksums of bytes.PBKDF2 Hash GeneratorDerive PBKDF2 keys from a password, salt and iteration count with SHA-1, SHA-256 or SHA-512.Protobuf DecoderDecode raw Protocol Buffers hex or Base64 without a schema, or add a .proto for field names.XML Escape / UnescapeEscape & < > " ' for XML text and attributes, unescape entities back, or wrap text in CDATA.Binary Search Tree VisualizerInsert, delete and find in BST, AVL and red-black trees with animated rotations and traversals.CSR GeneratorCreate a certificate signing request (CSR) and private key with SANs, RSA or ECDSA, in your browser.MongoDB ObjectId to TimestampDecode a MongoDB ObjectId to its creation date, or build ObjectIds from dates for range queries.PGP Encrypt / DecryptEncrypt, decrypt, sign and verify PGP messages with your armored keys, entirely offline.PGP Key GeneratorGenerate an OpenPGP key pair (Curve25519, NIST ECC or RSA) with passphrase and expiry, offline.Quoted-Printable Encoder / DecoderEncode or decode quoted-printable email text (MIME) with UTF-8 and 76-character soft line breaks.Self-Signed Certificate GeneratorCreate a self-signed SSL certificate and key for localhost or dev servers, as PEM or PFX.SHA-1 Hash GeneratorSHA-1 and HMAC-SHA1 of text or files in hex or Base64, plus Git blob hashes and verify.SHA-512 Hash GeneratorSHA-512 and SHA-384 hashes of text or files in hex or Base64, HMAC and hash verification.SRI Hash GeneratorCreate Subresource Integrity hashes (sha256/384/512) and ready <script> or <link> tags.SSH Key GeneratorGenerate Ed25519 or RSA SSH key pairs in your browser: OpenSSH public key plus private key.
See all 65 Encoders, Hashes & Crypto →