# feedparser

> Robust RSS Atom and RDF feed parsing using sax js

Latest version **2.6.0** (published 2026-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install feedparser
pnpm add feedparser
yarn add feedparser
bun add feedparser
```

Provides the command `feedparser`.

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.6.0 |
| Published | 2026-05-18 |
| First published | 2011-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10.18.1 |
| Dependencies | 9 |
| Unpacked size | 81.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1973 |
| Author | Dan MacTough |
| Maintainers | danmactough |
| Keywords | rss, feed, atom, rdf, xml, syndication, rsscloud, pubsubhubbub |

## Links

- npm: https://www.npmjs.com/package/feedparser
- Repository: https://github.com/danmactough/node-feedparser
- Homepage: http://github.com/danmactough/node-feedparser
- Issues: http://github.com/danmactough/node-feedparser/issues
- npm.io page: https://npm.io/package/feedparser

## Dependencies (9)

- [mri](https://npm.io/package/mri.md) ^1.1.5
- [sax](https://npm.io/package/sax.md) >=1.2.4 <1.4.4
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.has](https://npm.io/package/lodash.has.md) ^4.5.2
- [lodash.uniq](https://npm.io/package/lodash.uniq.md) ^4.5.0
- [addressparser](https://npm.io/package/addressparser.md) ^1.0.1
- [lodash.assign](https://npm.io/package/lodash.assign.md) ^4.2.0
- [readable-stream](https://npm.io/package/readable-stream.md) ^2.3.7
- [array-indexofobject](https://npm.io/package/array-indexofobject.md) ~0.0.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.6.0 (latest) — 2026-05-18
- 1.1.6 (1.x) — 2016-12-26
- 0.15.10 (0.15) — 2013-12-29
- 2.5.0 — 2026-05-18
- 2.4.2 — 2026-05-14
- 2.4.1 — 2026-05-14
- 2.4.0 — 2026-05-07
- 2.3.1 — 2026-03-27
- 2.3.0 — 2026-03-21
- 2.2.11 — 2026-03-21
- 2.3.0-1 — 2026-03-20
- 2.3.0-0 — 2026-03-20
- 2.2.10 — 2020-05-02
- 2.2.9 — 2018-01-28
- 2.2.8 — 2018-01-08
- … 95 more at https://npm.io/package/feedparser/versions

## README

# Feedparser - Robust RSS, Atom, and RDF feed parsing in Node.js

[![CI](https://github.com/danmactough/node-feedparser/actions/workflows/ci.yml/badge.svg)](https://github.com/danmactough/node-feedparser/actions/workflows/ci.yml)

[![NPM](https://nodei.co/npm/feedparser.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/feedparser/)

Feedparser is for parsing RSS, Atom, and RDF feeds in node.js.

It has a couple features you don't usually see in other feed parsers:

1. It resolves relative URLs (such as those seen in Tim Bray's "ongoing" [feed](https://www.tbray.org/ongoing/ongoing.atom)).
2. It properly handles XML namespaces (including those in unusual feeds
that define a non-default namespace for the main feed elements).

## Installation

```bash
npm install feedparser
```

## Usage

This example is just to briefly demonstrate basic concepts.

**Please** also review the [complete example](examples/complete.js) for a
thorough working example that is a suitable starting point for your app.

```js

var FeedParser = require('feedparser');
var fetch = require('node-fetch'); // for fetching the feed

var req = fetch('http://somefeedurl.xml')
var feedparser = new FeedParser([options]);

req.then(function (res) {
  if (res.status !== 200) {
    throw new Error('Bad status code');
  }
  else {
    // The response `body` -- res.body -- is a stream
    res.body.pipe(feedparser);
  }
}, function (err) {
  // handle any request errors
});

feedparser.on('error', function (error) {
  // always handle errors
});

feedparser.on('readable', function () {
  // This is where the action is!
  var stream = this; // `this` is `feedparser`, which is a stream
  var meta = this.meta; // **NOTE** the "meta" is always available in the context of the feedparser instance
  var item;

  while (item = stream.read()) {
    console.log(item);
  }
});

```

You can also consume feeds using async iteration.

When using async iteration, prefer `stream.pipeline(...)` (or a promisified
`stream.pipeline`) so stream errors are handled before data starts flowing. Async iterator usage with `pipeline` requires Node v12+.
If you use `pipe()` or otherwise start writing to `FeedParser` before iteration
begins, attach an `error` handler on `feedparser` yourself.

```js
var FeedParser = require('feedparser');
var fetch = require('node-fetch');
// stream/promises requires Node v15+ but the same behavior can be
// attained by promisifying require('stream').pipeline
var pipeline = require('stream/promises').pipeline;

async function main() {
  var res = await fetch('http://someurl.site/rss.xml');
  if (res.status !== 200) throw new Error('Bad status code');

  var feedparser = new FeedParser(options);

  try {
    await pipeline(
      res.body,
      feedparser,
      async function (feedparserIterable) {
        for await (var item of feedparserIterable) {
          console.log(item.title);
        }
      }
    )
  } catch (err) {
    console.error(err);
  }
}

main();

```

You can also check out this nice [working implementation](https://github.com/scripting/feedRead) that demonstrates one way to handle all the hard and annoying stuff. :smiley:

### options

- `normalize` - Set to `false` to override Feedparser's default behavior,
  which is to both parse feeds into an object that contains the generic properties
  patterned after (although not identical to) the RSS 2.0 format, regardless
  of the feed's format, as well as to resolve all relative urls, including those
  embedded in HTML content fields.

- `addmeta` - Set to `false` to override Feedparser's default behavior, which
  is to add the feed's `meta` information to each article.
  Feed metadata is available as soon as Feedparser has enough information to
  emit the first article. While bad practice and borderline pathological, feeds
  can legally include additional channel metadata after articles, so the `meta`
  object may be enriched until the stream ends. If you need complete metadata,
  also handle the `meta` event and keep the emitted object until the stream ends.
  If you only need the metadata available when each article streams, you can
  use `item.meta` as usual.

- `guidlink` - Set to `false` to override Feedparser's default behavior, which
  is to use an RSS item's `guid` as the item `link` when the item has no `link`
  and the `guid` starts with `http:` or `https:`.

- `feedurl` - The url (string) of the feed. FeedParser is very good at
  resolving relative urls in feeds, including those embedded in HTML content
  fields. But some feeds use relative urls without declaring the `xml:base`
  attribute any place in the feed. This is perfectly valid, but we don't know
  the feed's url before we start parsing the feed and trying to resolve those
  relative urls. If we discover the feed's url, we will go back and resolve the
  relative urls we've already seen, but this takes a little time (not much).
  If you want to be sure we can resolve all relative urls, you should set the
  `feedurl` option.

- `resume_saxerror` - Set to `false` to override Feedparser's default behavior, which
  is to silently handle them and then automatically resume parsing. In
  my experience, `SAXErrors` are not usually fatal, so this is usually helpful
  behavior. If you prefer to abort parsing the feed when there's a `SAXError`,
  set `resume_saxerror` to `false`, which will cause the `SAXError` to be emitted
  on `error` and abort parsing.

## Examples

See the [`examples`](examples/) directory.

## API

### Transform Stream

Feedparser is a [transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) operating in "object mode": XML in -> Javascript objects out.
Each readable chunk is an object representing an article in the feed.

### Events Emitted

* `meta` - called with feed `meta` when it has been parsed
* `error` - called with `error` whenever there is a fatal Feedparser error. SAXErrors are only emitted here when `resume_saxerror` is `false`; otherwise they are silently collected in `feedparser.errors`.

## What is the parsed output produced by feedparser?

Feedparser parses each feed into a `meta` (emitted on the `meta` event) portion
and one or more `articles` (emited on the `data` event or readable after the `readable`
is emitted).

Regardless of the format of the feed, the `meta` and each `article` contain a
uniform set of generic properties patterned after (although not identical to)
the RSS 2.0 format, as well as all of the properties originally contained in the
feed. So, for example, an Atom feed may have a `meta.description` property, but
it will also have a `meta['atom:subtitle']` property.

The purpose of the generic properties is to provide the user a uniform interface
for accessing a feed's information without needing to know the feed's format
(i.e., RSS versus Atom) or having to worry about handling the differences
between the formats. However, the original information is also there, in case
you need it. In addition, Feedparser supports some popular namespace extensions
(or portions of them), such as portions of the `itunes`, `media`, `feedburner`
and `pheedo` extensions. So, for example, if a feed article contains either an
`itunes:image` or `media:thumbnail`, the url for that image will be contained in
the article's `image.url` property.

All generic properties are "pre-initialized" to `null` (or empty arrays or
objects for certain properties). This should save you from having to do a lot of
checking for `undefined`, such as, for example, when you are using jade
templates.

In addition, all properties (and namespace prefixes) use only lowercase letters,
regardless of how they were capitalized in the original feed. ("xmlUrl" and
"pubDate" also are still used to provide backwards compatibility.) This decision
places ease-of-use over purity -- hopefully, you will never need to think about
whether you should camelCase "pubDate" ever again.

The `title` and `description` properties of `meta` and the `title` property of
each `article` have any HTML stripped if you let feedparser normalize the output.
If you really need the HTML in those elements, there are always the originals:
e.g., `meta['atom:subtitle']['#']`.

### List of meta properties

* title
* description
* link (website link)
* xmlurl (the canonical link to the feed, as specified by the feed)
* date (most recent update)
* pubdate (original published date)
* author
* language
* image (an Object containing `url` and `title` properties)
* favicon (a link to the favicon -- only provided by Atom feeds)
* copyright
* generator
* categories (an Array of Strings)

### List of article properties

* title
* description (frequently, the full article content)
* summary (frequently, an excerpt of the article content)
* link
* origlink (when FeedBurner or Pheedo puts a special tracking url in the `link` property, `origlink` contains the original link)
* permalink (when an RSS feed has a `guid` field and the `isPermalink` attribute is not set to `false`, `permalink` contains the value of `guid`)
* date (most recent update)
* pubdate (original published date)
* author
* guid (a unique identifier for the article)
* comments (a link to the article's comments section)
* image (an Object containing `url` and `title` properties)
* categories (an Array of Strings)
* source (an Object containing `url` and `title` properties pointing to the original source for an article; see the [RSS Spec](https://cyber.law.harvard.edu/rss/rss.html#ltsourcegtSubelementOfLtitemgt) for an explanation of this element)
* enclosures (an Array of Objects, each representing a podcast or other enclosure and having a `url` property and possibly `type` and `length` properties)
* meta (an Object containing all the feed meta properties; especially handy when using the EventEmitter interface to listen to `article` emissions)

## Help

- Don't be afraid to report an [issue](https://github.com/danmactough/node-feedparser/issues).

## Contributors

View all the [contributors](https://github.com/danmactough/node-feedparser/graphs/contributors).

Although `node-feedparser` no longer shares any code with `node-easyrss`, it was
the original inspiration and a starting point.

## License

(The MIT License)

Copyright (c) 2011-2026 Dan MacTough and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the 'Software'), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/feedparser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
