Calculate the size of a Firestore document in bytes

Paste a document as JSON and get its Firestore size in bytes, the share of the 1 MiB limit and the biggest fields.

How it works

  1. Paste the document JSON and, if you have it, its path
  2. Read the size in bytes and the share of the 1 MiB limit
  3. Check the biggest fields and the depth

How Firestore counts a document

A Firestore document is the sum of its document name, the size of each field name, the size of each field value and 32 extra bytes, and this page adds those up exactly as Google's Storage size calculations page defines them. A string is its UTF-8 bytes plus 1, and that rule applies to collection IDs, document IDs, field names and string values alike. The document name is every collection ID and document ID in the path as strings, plus 16. Values are 8 bytes for a number, 1 for a boolean or null, 8 for a timestamp, 16 for a geopoint, the byte length for bytes, the document name size for a reference, 8 bytes per dimension for a vector, and the sum of the contents for an array or a map. Documents in subcollections are not part of the parent.

A worked example

Google's own example is the document users/jeff/tasks/my_task_id with the fields type: Personal, done: false, priority: 1 and description: Learn Cloud Firestore. The name is 6 + 5 + 6 + 11 + 16 = 44 bytes. The field names add 5 + 5 + 9 + 12 = 31 bytes and the values add 9 + 1 + 8 + 22 = 40 bytes, which is 71 bytes of fields. With the 32 extra bytes the document is 44 + 71 + 32 = 147 bytes, 0.01 percent of the limit. The page opens with exactly this document. A nested one: title: Hi, owner: {id: 7, ok: true}, tags: [a, bc] and nothing: null at the same path is 81 bytes of fields and 157 bytes in all. The owner map alone is 6 bytes for its name plus 47 for the map: 32 for the map itself, 11 for id and 4 for ok.

Plain JSON and Firestore REST exports

Paste either form. Plain JSON is treated by what JSON can say: every number is 8 bytes, a string is a string and an object is a map. JSON cannot tell a timestamp, a geopoint, a reference or bytes from a string or a map, so an ISO date written as text counts as a string. The Admin SDK writes timestamps as {_seconds, _nanoseconds} and geopoints as {_latitude, _longitude}; with the toggle on those are counted as 8 and 16 bytes. A Firestore REST export, with fields such as {stringValue: ...}, is detected automatically and carries the true types. Its name field supplies the path when the path box is empty. A bytesValue is measured after base64 decoding, and a referenceValue by its document path.

Limits and what is not counted

The page compares the total with the 1 MiB document limit of 1,048,576 bytes, reports how deep maps and arrays are nested against the limit of 20 levels, and flags field names over 1,500 bytes. Up to three limits of your own, such as a size you want to stay under, show as percentages. Google sizes a map the same way as a document, so every map, nested ones included, adds 32 bytes plus its field names and values. The page also flags a single field value over 1,048,487 bytes, a collection or document ID over 1,500 bytes and a nested field path over 1,500 bytes. Index entries are not calculated. They are stored separately, have their own size rules and their own limit, and need to know which indexes exist, which a pasted document does not show. The result is the size by Google's documented rules.

Frequently asked questions

How do I calculate the size of a Firestore document?

Add the document name (each collection and document ID as UTF-8 bytes plus 1, then plus 16), every field name (UTF-8 bytes plus 1), every field value, and 32 bytes. For users/jeff/tasks/my_task_id with four small fields that is 44 + 71 + 32 = 147 bytes. Paste the JSON here and the page does the sum.

What is the maximum size of a Firestore document?

1 MiB, which is 1,048,576 bytes, by Google's quotas page. A single field value can be at most 1 MiB minus 89 bytes (1,048,487 bytes). The result also shows the share of that limit, so a 262,144 byte document reads 25.00 percent.

Why is my JSON file bigger or smaller than the Firestore size?

JSON writes numbers as text and adds quotes, commas and spaces. Firestore counts a number as 8 bytes, a boolean as 1 and a string as its UTF-8 bytes plus 1, and it adds the field names and the path. A file full of one-digit numbers is mostly punctuation in JSON, but each of those numbers is 8 bytes in Firestore.

Do nested maps and arrays count toward the 1 MiB?

Yes. An array counts as the sum of its values. A map counts like a document: 32 bytes plus its field names and values, so an empty map is 32 bytes. Subcollection documents do not count toward the parent. Depth is limited to 20 levels of maps and arrays; a map inside an array inside a map is 3 levels.

Does this include index entry sizes?

No. Index entries, such as the 109 bytes Google shows for a collection-scope index on one boolean field, depend on which indexes exist and are stored separately. This page calculates the document only.

Is my document uploaded?

No. The text is processed in your browser and not uploaded. Your document and path are not saved; only the option settings and any custom limit names are kept on this device.