High-performance RSS/Atom/JSON Feed parser for Node.js
npm install feedparser-rs


High-performance RSS/Atom/JSON Feed parser for Node.js, written in Rust.
Drop-in replacement for Python's feedparser library, offering 10-100x performance improvement.
- Fast: Written in Rust, 10-100x faster than Python feedparser
- Tolerant: Handles malformed feeds with bozo flag (like feedparser)
- Multi-format: RSS 0.9x/1.0/2.0, Atom 0.3/1.0, JSON Feed 1.0/1.1
- HTTP fetching: Built-in URL fetching with compression support
- TypeScript: Full TypeScript definitions included
- Zero-copy: Efficient parsing with minimal allocations
``bash`
npm install feedparser-rsor
yarn add feedparser-rsor
pnpm add feedparser-rs
> [!IMPORTANT]
> Requires Node.js 18 or later.
`javascript
import { parse } from 'feedparser-rs';
const feed = parse(
https://example.com/1
);
console.log(feed.feed.title); // "My Blog"
console.log(feed.entries[0].title); // "Hello World"
console.log(feed.version); // "rss20"
`
Fetch and parse feeds directly from URLs:
`javascript
import { fetchAndParse } from 'feedparser-rs';
const feed = await fetchAndParse('https://example.com/feed.xml');
console.log(feed.feed.title);
console.log(Fetched ${feed.entries.length} entries);`
> [!TIP]
> fetchAndParse automatically handles compression (gzip, deflate, brotli) and follows redirects.
`javascript
import { parse } from 'feedparser-rs';
const response = await fetch('https://example.com/feed.xml');
const buffer = Buffer.from(await response.arrayBuffer());
const feed = parse(buffer);
`
Parse a feed from bytes or string.
Parameters:
- source - Feed content as Buffer, string, or Uint8Array
Returns:
- ParsedFeed object with feed metadata and entries
Throws:
- Error if parsing fails catastrophically
Fetch and parse a feed from URL.
Parameters:
- url - Feed URL to fetch
Returns:
- Promise resolving to ParsedFeed object
Detect feed format without full parsing.
Returns:
- Format string: "rss20", "atom10", "json11", etc.
`javascript`
const format = detectFormat('
console.log(format); // "atom10"
`typescript`
interface ParsedFeed {
feed: FeedMeta;
entries: Entry[];
bozo: boolean;
bozo_exception?: string;
encoding: string;
version: string;
namespaces: Record
}
`typescript`
interface FeedMeta {
title?: string;
title_detail?: TextConstruct;
link?: string;
links: Link[];
subtitle?: string;
updated?: number; // Milliseconds since epoch
author?: string;
authors: Person[];
language?: string;
image?: Image;
tags: Tag[];
id?: string;
ttl?: number;
}
`typescript`
interface Entry {
id?: string;
title?: string;
link?: string;
links: Link[];
summary?: string;
content: Content[];
published?: number; // Milliseconds since epoch
updated?: number;
author?: string;
authors: Person[];
tags: Tag[];
enclosures: Enclosure[];
}
> [!NOTE]
> See index.d.ts for complete type definitions including Link, Person, Tag, Image, Enclosure, and more.
The library uses a "bozo" flag (like feedparser) to indicate parsing errors while still returning partial results:
`javascript
const feed = parse('
if (feed.bozo) {
console.warn('Feed has errors:', feed.bozo_exception);
}
// Still can access parsed data
console.log(feed.feed.title); // "Broken"
`
All date fields are returned as milliseconds since Unix epoch. Convert to JavaScript Date:
`javascript`
const entry = feed.entries[0];
if (entry.published) {
const date = new Date(entry.published);
console.log(date.toISOString());
}
Benchmarks on Apple M1 Pro:
| Feed Size | Time | Throughput |
|-----------|------|------------|
| Small (2 KB) | 0.01 ms | 187 MB/s |
| Medium (20 KB) | 0.09 ms | 214 MB/s |
| Large (200 KB) | 0.94 ms | 213 MB/s |
| Operation | feedparser-rs | Python feedparser | Speedup |
|-----------|---------------|-------------------|---------|
| Parse 20 KB RSS | 0.09 ms | 8.5 ms | 94x |
| Parse 200 KB RSS | 0.94 ms | 85 ms | 90x |
> [!TIP]
> For best performance, pass Buffer instead of string to avoid UTF-8 conversion overhead.
Pre-built binaries available for:
| Platform | Architecture |
|----------|--------------|
| macOS | Intel (x64), Apple Silicon (arm64) |
| Linux | x64, arm64 |
| Windows | x64 |
Supported Node.js versions: 18, 20, 22+
`bashInstall dependencies
npm install
Licensed under either of:
- Apache License, Version 2.0
- MIT License
at your option.