Robust and fast JavaScript parser and generator for RSS, Atom, JSON Feed, and RDF feeds, with support for popular namespaces and OPML files.
Feedsmith provides both universal and format-specific parsers that maintain the original feed structure in a clean, object-oriented format while intelligently normalizing legacy elements. Access all feed data without compromising simplicity.
Important
You're viewing the README for the next version of Feedsmith (v2.0), which includes major improvements and breaking changes. While the codebase is stable, the API may still undergo slight changes. This version is currently only available through the next
channel for early testing. For production use, it is recommended to use the latest stable version.
npm install feedsmith@latest # Stable version 1.9.0
npm install feedsmith@next # Development version 2.0.0-next.x
Read full docs ↗ · Quick Start · Why Feedsmith? · Benchmarks →
- Comprehensive Support 🎯 — Supports all major feed formats and feed namespaces.
- Perserves Structure 📦 — Parsed feed object maintains the original feed structure making it easy to access the data.
- Smart Namespace Handling 🧠 — Automatically normalizes custom namespace prefixes to standard ones (e.g.,
<custom:creator>
becomesdc.creator
). - Parsing & Generating 🔩 — You can use one package for both parsing and generating feeds.
- Normalizes Legacy Elements ✨ — Upgrades feed elements to their modern equivalents so that you never need to worry about reading feeds in older formats.
- CaSe INSENsiTive 🐍 — Handles fields and attributes in any case (lowercase, uppercase, mixed).
- Forgiving 🤝 — Handles malformed or incomplete feeds gracefully. It will extract whatever valid data it can find and ignore missing or invalid elements. This makes it suitable for use with real-world feeds that may not strictly follow specifications.
- Ultrafast parsing ⚡ — One of the fastest feed parsers in JavaScript (see benchmarks).
- Type-safe API 🛟 — Built with TypeScript from the ground up, it provides complete type definitions for every feed format and namespace.
- Tree-shakable 🍃 — Only include the parts of the library you need, reducing bundle size.
- Well-tested 🔬 — Comprehensive test suite with over 2000 tests and 99% code coverage.
- Works in Node.js and modern browsers.
- Works with plain JavaScript, you don't need to use TypeScript.
Feedsmith aims to fully support all major feed formats and namespaces in complete alignment with their specifications.
✅ Available · ⌛️ Work in progress · 📋 Planned
Format | Versions | Parsing | Generating |
---|---|---|---|
RSS | 0.9x, 2.0 | ✅ | ✅ |
Atom | 0.3, 1.0 | ✅ | ✅ |
JSON Feed | 1.0, 1.1 | ✅ | ✅ |
RDF | 0.9, 1.0 | ✅ | ⏳ |
Name | Prefix | Supported in | Parsing | Generating |
---|---|---|---|---|
Atom | <atom:*> |
RSS, RDF | ✅ | ✅ |
Dublin Core | <dc:*> |
RSS, Atom, RDF | ✅ | ✅ |
Syndication | <sy:*> |
RSS, Atom, RDF | ✅ | ✅ |
Content | <content:*> |
RSS, RDF | ✅ | ✅ |
Slash | <slash:*> |
RSS, Atom, RDF | ✅ | ✅ |
iTunes | <itunes:*> |
RSS, Atom | ✅ | ✅ |
Podcast | <podcast:*> |
RSS | ✅ | ✅ |
Media RSS | <media:*> |
RSS, Atom, RDF | ✅ | ✅ |
GeoRSS-Simple | <georss:*> |
RSS, Atom, RDF | ✅ | ✅ |
Atom Threading | <thr:*> |
RSS, Atom | ✅ | ✅ |
Dublin Core Terms | <dcterms:*> |
RSS, Atom, RDF | ✅ | ✅ |
Well-Formed Web | <wfw:*> |
RSS, Atom, RDF | ✅ | ✅ |
YouTube | <yt:*> |
Atom | ✅ | ✅ |
Administrative | <admin:*> |
📋 | 📋 | 📋 |
GML | <gml:*> |
📋 | 📋 | 📋 |
GeoRSS GML | <georss:*> |
📋 | 📋 | 📋 |
Format | Versions | Parsing | Generating |
---|---|---|---|
OPML | 1.0, 2.0 | ✅ | ✅ |
This guide will get you up and running with Feedsmith in just a few minutes.
Important
For a full overview of all the features, visit the documentation website.
npm install feedsmith
The simplest way to parse any feed is to use the universal parseFeed
function:
import { parseFeed } from 'feedsmith'
// Works with RSS, Atom, JSON Feed, and RDF
const { format, feed } = parseFeed(feedContent)
console.log('Feed format:', format) // rss, atom, json, rdf
console.log('Feed title:', feed.title)
if (format === 'rss') {
console.log('RSS feed link:', feed.link)
}
If you know the format in advance, you can use the format-specific parsers:
import {
parseAtomFeed,
parseJsonFeed,
parseRssFeed,
parseRdfFeed
} from 'feedsmith'
// Parse specific formats
const atomFeed = parseAtomFeed('atom content')
const jsonFeed = parseJsonFeed('json content')
const rssFeed = parseRssFeed('rss content')
const rdfFeed = parseRdfFeed('rdf content')
// Access typed data
rssFeed.title
rssFeed.dc?.creator
rssFeed.items?.[0]?.title
import { parseOpml } from 'feedsmith'
const opml = parseOpml('opml content')
opml.head?.title
opml.body?.outlines?.[0].text
opml.body?.outlines?.[1].xmlUrl
import { generateRssFeed } from 'feedsmith'
const rss = generateRssFeed({
title: 'My Blog',
link: 'https://example.com',
description: 'A simple blog',
items: [{
title: 'Hello World',
link: 'https://example.com/hello',
description: 'My first post',
pubDate: new Date()
}]
})
console.log(rss) // Complete RSS XML
// You can also generate other formats:
// - generateAtomFeed() for Atom feeds
// - generateJsonFeed() for JSON feeds
// - generateRdfFeed() for RDF feeds
// - generateOpml() for OPML files
try {
const { format, feed } = parseFeed(content)
// Use the feed
} catch (error) {
console.error('Invalid feed:', error.message)
}
Why should you use this library over the alternatives?
The key advantage of Feedsmith is that it preserves the original feed structure exactly as defined in each specific feed format.
Many alternative packages attempt to normalize data by:
- Merging distinct fields like
author
,dc:creator
, andcreator
into a single property. - Combining date fields such as
dc:date
andpubDate
without preserving their sources. - Handling multiple
<atom:link>
elements inconsistently, sometimes keeping only the first or last one or ignoring differentrel
attributes. - Some libraries try to combine different feed formats into one universal structure.
While this approach can be useful for quick reading of feed data, it often results in a loss of information that may be crucial for certain applications, such as reading data from specific namespaces.
- The library API is inspired by the FeedKit library for Swift.
- XML parsing is provided by fast-xml-parser.
- HTML entity decoding is handled by entities.
Licensed under the MIT license.
Copyright 2025 Maciej Lamberski