Registry / database / firestore-parser

firestore-parser

JSON →
library0.9.0jsnpmunverified

Library to parse Firestore REST API JSON responses into plain JavaScript objects. v0.9.0 (latest) - stable, maintenance mode. Transforms Firestore's verbose type-keyed format (e.g., {stringValue: "foo"}) into natural JS types (e.g., "foo"). Unlike manual mapping or generic JSON manipulation, this library handles all Firestore value types recursively, including nested maps, arrays, timestamps, and references. Ideal for developers working directly with Firestore's REST API (not client SDK) who need clean output.

npm install firestore-parser
INSTALL
IMPORT
SIG · FIRESTORE-PARSER
F
firestore-parser
databasejavascriptv0.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FireStoreParser
✓ import FireStoreParser from 'firestore-parser'
✗ const FireStoreParser = require('firestore-parser')
Library ships ESM only (no CJS export). Use import, not require. Also, note case-sensitive: FireStoreParser (capital F, S, P).

Parses a Firestore REST API response (with stringValue, integerValue, etc.) into a plain JS object with native types.

import FireStoreParser from 'firestore-parser'; // sample Firestore REST API response const firestoreResponse = { name: 'projects/my-project/databases/(default)/documents/players/steve', fields: { name: { stringValue: 'steve' }, health: { integerValue: '100' }, alive: { booleanValue: true }, position: { mapValue: { fields: { x: { doubleValue: 10.5 }, y: { doubleValue: 20.3 } } } }, inventory: { arrayValue: { values: [{ stringValue: 'sword' }, { stringValue: 'shield' }] } }, createdAt: { timestampValue: '2023-01-15T12:00:00Z' }, ref: { referenceValue: 'projects/my-project/databases/(default)/documents/items/123' } } }; const parsed = FireStoreParser(firestoreResponse); console.log(parsed); // => { // name: 'steve', // health: 100, // alive: true, // position: { x: 10.5, y: 20.3 }, // inventory: ['sword', 'shield'], // createdAt: '2023-01-15T12:00:00Z', // ref: 'projects/my-project/databases/(default)/documents/items/123' // }
Debug
Known issues
gotchaE Only: This package is ESM-only since v0.8.0. Using require() will throw a runtime error.
fix
Use import FireStoreParser from 'firestore-parser' or dynamic import(). For CommonJS projects, use async import or downgrade to v0.7.1.
affects: >=0.8.0
gotchaNo type definitions: The package does not ship TypeScript declarations. You will get implicit 'any' or need to write your own types.
fix
Create a .d.ts file: declare module 'firestore-parser' { export default function FireStoreParser(json: any): any; }
affects: *
gotchaInput must be Firestore REST response object, not DocumentSnapshot or client SDK object. Passing a Firestore client SDK DocumentSnapshot will produce unexpected results.
fix
Only pass the JSON from firestore.googleapis.com REST API response (e.g., the result of fetch(url).then(r => r.json())).
affects: *
gotchaTimestamp values are returned as strings (ISO 8601), not Date objects. This may be surprising if you expected native Date.
fix
Manually convert: new Date(parsed.createdAt) if needed.
affects: *
Errors
Common errors & fixes
const FireStoreParser = require('firestore-parser'); ^ TypeError: FireStoreParser is not a function
Using require() on an ESM-only package with a default export. The require() returns the module namespace object, not the default export.
fix
Use import FireStoreParser from 'firestore-parser' in an ESM context, or use dynamic import: const { default: FireStoreParser } = await import('firestore-parser').
Property 'stringValue' does not exist on type 'Object'.
TypeScript cannot infer the shape of the Firestore response object, leading to type errors when accessing fields manually.
fix
Define an interface for the Firestore response or use the library's return type (it returns any). Prefer not to manually access fields; instead pass the whole response to FireStoreParser.
Cannot find module 'firestore-parser' or its corresponding type declarations.
The package has no bundled TypeScript declaration files, so TypeScript projects may fail to resolve types.
fix
Install @types/firestore-parser? (none exists). Instead, declare module manually as described in warnings. Alternatively, use // @ts-ignore.
Upgrade
Version history
0.9.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
firestore-parser — npm install firestore-parser · libregistry