Blog
ESP32 SPIFFS and LittleFS
A filesystem inside the flash chip — configs, web pages, logs, no SD card required. This covers what is spiffs esp32, how to use spiffs esp32, creating spiffs.bin for uploads, and when to switch to LittleFS or NVS instead.
What Is SPIFFS ESP32?
A real filesystem living inside the ESP32’s flash chip. Files appear at paths like /config.json and /index.html, and the Arduino core gives you open, read, and write calls just like an SD card — no extra hardware. The whole thing sits in a partition carved out of flash, typically 1-2 MB on a 4 MB chip.
How to Use SPIFFS ESP32?
#include <SPIFFS.h>, then SPIFFS.begin() in setup — that is the whole setup. Open a file with File f = SPIFFS.open("/data.txt", FILE_WRITE);, write with f.println("hello"), and close it when done. A file left open can lose data on power loss, so treat close() as part of every write. Mostly works exactly like the SD library API.
How to Create spiffs.bin for ESP32?
Two paths. In Arduino IDE, install the ESP32 Sketch Data Upload plugin, drop your files in a data/ folder beside the sketch, and it builds and flashes the image for you. For headless builds, mkspiffs packs the folder into a binary with the partition size: mkspiffs -c data -s 0x1F0000 spiffs.bin. PlatformIO’s uploadfs does the same in one command.
SPIFFS or LittleFS — which should I use?
LittleFS, unless you need SPIFFS for legacy code. It wears flash more evenly, handles corruption better, and in recent Arduino cores SPIFFS.begin() is implemented on top of LittleFS anyway, so the debate is mostly settled. New projects: use LittleFS.begin() with the same file API.
How much space do I get?
Depends on your board’s partition table. Default Arduino schemes give the filesystem roughly 1.5 MB on a 4 MB module; the No OTA and Huge APP options change the split. Read Tools → Partition Scheme before you wonder why the disk is small — it is not a secret, just an IDE dropdown.
SPIFFS.begin() fails — why?
The classic failure is a corrupt filesystem, and the chip tells you: E (386) SPIFFS: mount failed. Typical causes: erase_flash wiped the partition mid-project, the partition table changed, or power died during a write. Fix: format on first boot with SPIFFS.format(true), or just re-upload the data folder.
Why does everything vanish after reflash?
Because esptool.py erase_flash erases the whole chip — firmware, filesystem, NVS, everything. Changing the partition scheme also reformats. I watched my WiFi credentials vanish twice this way before I started keeping a backup copy of the data folder. The flashing guide covers exactly what gets erased.
How do I store a config file?
JSON is the usual format: read /config.json with ArduinoJson, parse it into a struct, and write it back on change. The pattern that works: load in setup(), save only when something changes, and keep the file small — a 4 KB config is plenty for most projects. Example projects show the full round trip.
Can I store images or binary data?
Yes — a web server can serve PNG and JPEG straight from the filesystem, which is how most ESP32 dashboard and camera projects work. Write binary data in chunks; one giant write can trip partition block boundaries. Keep an eye on free space — both SPIFFS and LittleFS get slower as the disk fills.
What about NVS — isn’t that also storage?
NVS is the key-value store that the Preferences library wraps — tiny settings, counters, credentials, with wear leveling built for frequent small updates. Use NVS for settings, the filesystem for files. The rule of thumb: a calibration float goes in Preferences; a web page goes in LittleFS. The FAQ index sorts the rest.
Write, List, Read Back — In Your Browser
File storage on ESP32 is a three-verb skill — write, list, read — and the whole cycle runs free in our simulator on a real SD stack:
- microSD card on ESP32 — the complete happy path, plus the failure branch:
microSD demo - ESP32
Card ready.
Files on card:
/log.txt 128 bytes
Wrote /log.txt
Read back: (your data, verbatim)
Done.
And when the wiring is wrong, you get the line you would get on a bench: SD.begin() FAILED - check the wiring. Mount, persist, verify — the same workflow you will repeat with SPIFFS/LittleFS partitions on real hardware.