How to convert an excel file to base64 for email api attachments
- Step 1Upload the report to attach — Drop the
.xlsx/.xls/.ods/.csvexport you want to email. Only spreadsheet extensions are selectable. - Step 2Encode in the browser — The bytes are read with
file.arrayBuffer(), chunked, and encoded withbtoa()— locally, with no server round-trip. - Step 3Check the byte count vs. provider limit — Line 1 shows the size; compare against your provider's cap (SendGrid ~30 MB total, Postmark 10 MB) before building the request.
- Step 4Copy and strip the header — Copy the whole block, then delete the two
//lines and blank line. The remainder is thecontentvalue. - Step 5Use the printed MIME for the type field — Line 2 is the exact MIME — paste it into
type(SendGrid) orContentType(Postmark). - Step 6Assemble the attachment object — Build the provider's attachment entry: content/Content = raw Base64, type/ContentType = MIME, filename/Name = your file name.
Attachment field names by email provider
Map the tool's two outputs (raw Base64 + printed MIME) onto each provider's JSON. Size caps are the providers' documented per-message limits; confirm against current docs.
| Provider | Base64 field | MIME field | Filename field | Attachment size cap |
|---|---|---|---|---|
| SendGrid (v3 Mail Send) | content | type | filename | ~30 MB total per message |
| Postmark | Content | ContentType | Name | 10 MB per message |
| Mailgun | attachment (or file part) | (inferred / Content-Type) | (filename) | ~25 MB per message |
| AWS SES (v2 raw/JSON) | raw MIME body (Base64 part) | Content-Type header | Content-Disposition name | ~40 MB per message |
What the output text contains
The email API needs the raw Base64 (Line 4+) for the content field and the MIME (Line 2) for the type field. Strip Lines 1 and 3.
| Line | Example content | Keep it for API use? |
|---|---|---|
| Line 1 | // Base64-encoded: report.xlsx (48,213 bytes) | No — strip it |
| Line 2 | // MIME type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | No — but copy the MIME value into your payload |
| Line 3 | (blank separator line) | No — strip it |
| Line 4+ | UEsDBBQABg... (the raw Base64, no data: prefix) | Yes — this is the only part the API needs |
File-size limits by plan (excel family)
The JAD plan cap limits what you can encode; the provider cap limits what you can send. Remember Base64 is ~33% larger, but providers usually measure the original attachment size.
| Plan | Max source file | Approx. Base64 output (+33%) | Files per run |
|---|---|---|---|
| Free | 5 MB | ~6.7 MB | 1 |
| Pro | 50 MB | ~66.5 MB | 5 |
| Pro-media | 200 MB | ~266 MB | 20 |
| Developer | 500 MB | ~665 MB | unlimited |
Cookbook
Provider-shaped attachment objects built from the tool's literal output. The content/Content value is always the raw Base64 with the // header removed.
SendGrid v3 attachment
SendGrid expects Base64 in content and the MIME in type. Both come straight from the tool.
Tool output:
// Base64-encoded: weekly-report.xlsx (38,512 bytes)
// MIME type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
UEsDBBQABg...
"attachments": [{
"content": "UEsDBBQABg...",
"type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"filename": "weekly-report.xlsx",
"disposition": "attachment"
}]Postmark attachment
Postmark uses PascalCase keys: Content, Name, ContentType.
"Attachments": [{
"Name": "weekly-report.xlsx",
"Content": "UEsDBBQABg...",
"ContentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}]Check the report fits the provider cap
Postmark caps at 10 MB per message. Read line 1 before you build the request — if the original is near the cap, the Base64 plus the email body may still pass since providers measure decoded size, but verify.
// header: weekly-report.xlsx (9,800,000 bytes ≈ 9.8 MB) Postmark cap: 10 MB -> OK, but slim margin; trim sheets if you can
Mailgun JSON-style attachment
Mailgun typically takes multipart file parts, but its JSON sending paths and many wrappers accept a Base64 attachment value.
{
"from": "reports@example.com",
"to": "client@acme.com",
"subject": "Weekly report",
"attachment": "UEsDBBQABg...",
"attachment_filename": "weekly-report.xlsx"
}AWS SES raw-message MIME part
SES raw/JSON sends embed the Base64 as a MIME body part. Use the printed MIME and a Content-Transfer-Encoding of base64.
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name="weekly-report.xlsx" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="weekly-report.xlsx" UEsDBBQABg...
Edge cases and what actually happens
Comment header left in the content field
Send failsIf content starts with // Base64-encoded:, the recipient gets a corrupt attachment (or the API rejects it). Strip the two // lines and the blank line first.
Attachment over the provider cap
Rejected by providerPostmark refuses messages over 10 MB; SendGrid over ~30 MB total. Trim the workbook, zip it, or use a download link instead of an inline attachment.
MIME printed as application/octet-stream
Wrong attachment typeIf the browser couldn't classify the file, the type field would be generic and the recipient's client may not recognise it as Excel. Set the correct Office MIME by hand.
Expecting a data: URI for the content field
By designEmail APIs want raw Base64 in content/Content, which is what the tool emits. Do not add a data: prefix for these providers.
Encoding a .csv report
SupportedCSV encodes fine (MIME text/csv) and attaches as a spreadsheet most clients open in Excel. Use text/csv (printed) in the type field.
Free tier on a large monthly export
RejectedFree caps at 5 MB source. A big multi-tab export needs Pro (50 MB) to encode — though the provider's send cap still applies separately.
Truncated Base64 from copy
Corrupt attachmentCopying a multi-MB string can drop characters. Download name.b64.txt instead and verify decoded length against the byte count.
Inline vs. attachment disposition
By designThe tool only produces the Base64. Set disposition: attachment (SendGrid) or the equivalent in your payload — the tool has no say in how the provider renders it.
Need to scrub PII before emailing
Use sibling toolEncoding doesn't remove sensitive data. Redact first with the email/phone scrubber, then encode the cleaned file.
Frequently asked questions
Does SendGrid accept Base64 attachments?
Yes. SendGrid's v3 Mail Send endpoint takes attachments in the content field as raw Base64, with the MIME in type — exactly the two values this tool produces.
What MIME type should I use for an .xlsx attachment?
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. The tool prints it on line 2, so copy it into the provider's type field.
Which part of the output is the attachment content?
The raw Base64 below the blank line. Remove the two // comment lines and the blank separator first.
Is there an attachment size limit?
Providers differ: SendGrid ~30 MB total per message, Postmark 10 MB, Mailgun ~25 MB, SES ~40 MB. The byte count in the header helps you check before sending.
Should I include a data URI prefix in the content field?
No. Email APIs want raw Base64 with no prefix, which is what the tool outputs.
Does my client's spreadsheet get uploaded to encode it?
No — encoding is fully browser-side (file.arrayBuffer() + btoa()). The file never leaves your machine.
Can I attach a CSV the same way?
Yes. CSV encodes to Base64 with MIME text/csv; use that printed value in the type field.
Why does my attachment open as a generic file?
Likely a wrong/missing MIME (application/octet-stream). Set the correct Office MIME in the type/ContentType field.
What file types can I select?
.xlsx, .xls, .ods, .csv. Other extensions aren't selectable in this tool.
What's the JAD file-size limit for encoding?
Free 5 MB, Pro 50 MB, Pro-media 200 MB, Developer 500 MB — on the source file. This is separate from the provider's send cap.
Can I decode an attachment Base64 back here?
Not yet — decoding is planned. Use a decoder or atob() for now.
What should I do before encoding sensitive reports?
Redact with the email/phone scrubber and audit external links via the External Link Auditor, then encode the clean file.
Privacy first
Every JAD Excel tool runs entirely in your browser using SheetJS and ExcelJS. Your spreadsheets, formulas, and data never leave your device — verified by zero outbound network requests during processing.