--- name: html-file-formats description: > Load, inspect and save files inside a single-file HTML app (browser, no server): images (png/jpg/webp), svg, stl, json, yaml, csv, xls/xlsx, docx, pdf and zip - which pinned CDN library to use, how to read the file the user picks, extract text/tables/pixels/geometry from it, and generate a download of your own data in that format. Use whenever a web app must open or export one of these formats; for .doc or other formats without a browser parser it says what to do instead. --- # File formats in a browser app Everything runs in the page: the user picks a file (``), you parse it in JS, and you save by generating bytes and triggering a download. Nothing is written to disk by the app itself - "save" always means download. Verified library versions and calls: [formats.md](./formats.md). Copy the import map / script tags from there; pin versions, never `@latest`. | Format | Load (file -> data) | Save (data -> file) | Library | Notes | |---|---|---|---|---| | png / jpg / webp | `Image` + `` -> pixels, size | `canvas.toBlob(cb, 'image/png')` | none | jpg has no alpha; `toBlob('image/jpeg', 0.9)` | | svg | `DOMParser` -> DOM (paths, sizes); rasterize via `Image` | serialize DOM / build string | none; three.js `SVGLoader` for extrusion | keep `viewBox`; CSS inside `