# Firestore: 3 INVALID_ARGUMENT: The value of property "data" is longer than 1048487 bytes / Document exceeds the maximum size

**Code:** `Firestore: Document exceeds the maximum size of 1,048,576 bytes` · **Category:** Google Cloud / Firebase · **Seen on:** Google Cloud, JavaScript

A single Firestore document (all fields combined) went beyond the 1 MiB limit.

## Meaning

Firestore documents are small by design. Move large fields (images, JSON blobs, long arrays) to Cloud Storage and store references, split arrays into subcollections, and avoid ever-growing array fields. The limit also counts field names and nested data.

## Common causes

- Large base64 images or files stored in a field
- Unbounded arrays/maps growing over time
- Storing entire chat history in one document
- Embedded large JSON
- Index entries too many

## Quick fix

1. Store files in Cloud Storage and save URLs
2. Use subcollections instead of big arrays
3. Keep documents well below 1 MiB

## Detailed fix by platform

### Firebase

1. Check document size in the console (Data view) or estimate with `Buffer.byteLength(JSON.stringify(doc))`

## How to diagnose

1. **Size** — Document bytes?
2. **Field** — Largest field?
3. **Design** — Subcollection possible?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/gcp/firestore-document-too-large)
