kindle-highlights-parser
v0.1.2
Published
Parse Amazon Kindle `My Clippings.txt` exports into a normalized structure that can be used in any context, plus optional output helpers (CSV and JSON).
Readme
Kindle Clippings Parser
Parse Amazon Kindle My Clippings.txt exports into a normalized structure that
can be used in any context, plus optional output helpers (CSV and JSON).
Install
npm install kindle-highlights-parserUsage
The core parsing logic has no runtime dependencies and can be used in a browser or bundler.
import { parseClippings } from 'kindle-highlights-parser'
import { toCsv } from 'kindle-highlights-parser/outputs/csv'
import { toJson } from 'kindle-highlights-parser/outputs/json'
const fileText = await file.text() // e.g. from an <input type="file">
const { normalized } = parseClippings(fileText)
const csv = toCsv(normalized)
const json = toJson(normalized)CLI
Build the CLI and run it via npx or npm link:
npm run build
npm link
kindle-clippings parse "My Clippings.txt" --format json --pretty
kindle-clippings parse "My Clippings.txt" --format csvYou can also run it directly without linking:
node dist/cli.js parse "My Clippings.txt" --format json --pretty
node dist/cli.js parse "My Clippings.txt" --format csvOutput columns
titleauthortype(Highlight / Bookmark / Note)location_startlocation_endpage_startpage_endadded_on(ISO 8601)contentraw_metadata
Tests
npm install
npm run test # watch mode
npm run test:run # single runNotes
- The parser strips a UTF-8 BOM if present.
- Bookmarks usually have no
content. - Some files include
pageand/orlocation; missing values are left blank.
