Skip to content

Firestore errorFirestore: document exceeds the maximum size (1 MiB)

A Firestore document can be at most 1 MiB, which is 1,048,576 bytes. A write over the limit fails with INVALID_ARGUMENT. Common causes are an image saved as base64 text, or an array of messages or logs that grows inside one document.

Short answer

Find the field that is growing. Move images and files to Cloud Storage and save only the path or URL. Move lists that grow, such as chat messages or events, to a subcollection with one document per item. Split a large map into separate documents.

Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.

Why the document is too large, and the fix

  1. 01

    A file is stored in the document

    “Maximum size for a document 1 MiB (1,048,576 bytes)” Firebase, Usage and limits

    Base64 makes a file about a third bigger, so a photo of under 1 MB can still break the limit. Upload the file to Cloud Storage and save its path in the document.

  2. 02

    A list keeps growing in one document

    Chat messages, comments or logs added with arrayUnion grow until the writes start failing. Store each item as its own document in a subcollection, and add security rules for the new path.

    // one document per message, not one growing array
    await addDoc(collection(db, 'chats', chatId, 'messages'), {
      text,
      senderId: user.uid,
      createdAt: serverTimestamp(),
    });
  3. 03

    Several big fields add up

    “For example, four fields of 256 KiB each exceed the limit.” Google Cloud, Error codes (INVALID_ARGUMENT)

    The limit applies to the whole document, so fields that are fine on their own can be too much together. Split them into separate documents.

  4. 04

    Text is counted in bytes, not characters

    “String sizes are calculated as the number of UTF-8 encoded bytes + 1.” Firebase, Storage size calculations

    Field names and string values are counted as UTF-8 bytes, so emoji and non-Latin text use more space than they look. Long field names in big maps add up too.

Checked against the vendor’s docs on : Firebase docs: Usage and limits; Google Cloud docs: Firestore error codes; Firebase docs: Storage size calculations.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
All 127 Fiverr reviews

Related: Firestore transaction too big · Firestore quota exceeded · Firestore in query limit (30) · Firestore ALREADY_EXISTS

Questions

More on this error

Can I raise the 1 MiB limit?

No. It is a fixed Firestore limit, so the data has to move to Cloud Storage or into more documents.

Are existing large documents lost?

No. A write that is too large fails and the document keeps its last saved version. The data you tried to add isn’t saved.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.