Gathering detailed insights and metrics for rss-parser
Gathering detailed insights and metrics for rss-parser
Gathering detailed insights and metrics for rss-parser
Gathering detailed insights and metrics for rss-parser
npm install rss-parser
Typescript
Module System
Node Version
NPM Version
98.5
Supply Chain
99.6
Quality
76.1
Maintenance
100
Vulnerability
99.6
License
JavaScript (99.11%)
Shell (0.73%)
HTML (0.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,456 Stars
353 Commits
214 Forks
16 Watchers
10 Branches
50 Contributors
Updated on Jul 12, 2025
Latest Version
3.13.0
Package Id
rss-parser@3.13.0
Unpacked Size
1.79 MB
Size
476.15 kB
File Count
17
NPM Version
8.12.1
Node Version
18.4.0
Published on
Apr 11, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A small library for turning RSS XML feeds into JavaScript objects.
1npm install --save rss-parser
You can parse RSS from a URL (parser.parseURL
) or an XML string (parser.parseString
).
Both callbacks and Promises are supported.
Here's an example in NodeJS using Promises with async/await:
1let Parser = require('rss-parser');
2let parser = new Parser();
3
4(async () => {
5
6 let feed = await parser.parseURL('https://www.reddit.com/.rss');
7 console.log(feed.title);
8
9 feed.items.forEach(item => {
10 console.log(item.title + ':' + item.link)
11 });
12
13})();
When using TypeScript, you can set a type to control the custom fields:
1import Parser from 'rss-parser'; 2 3type CustomFeed = {foo: string}; 4type CustomItem = {bar: number}; 5 6const parser: Parser<CustomFeed, CustomItem> = new Parser({ 7 customFields: { 8 feed: ['foo', 'baz'], 9 // ^ will error because `baz` is not a key of CustomFeed 10 item: ['bar'] 11 } 12}); 13 14(async () => { 15 16 const feed = await parser.parseURL('https://www.reddit.com/.rss'); 17 console.log(feed.title); // feed will have a `foo` property, type as a string 18 19 feed.items.forEach(item => { 20 console.log(item.title + ':' + item.link) // item will have a `bar` property type as a number 21 }); 22})();
We recommend using a bundler like webpack, but we also provide pre-built browser distributions in the
dist/
folder. If you use the pre-built distribution, you'll need a polyfill for Promise support.
Here's an example in the browser using callbacks:
1<script src="/node_modules/rss-parser/dist/rss-parser.min.js"></script> 2<script> 3 4// Note: some RSS feeds can't be loaded in the browser due to CORS security. 5// To get around this, you can use a proxy. 6const CORS_PROXY = "https://cors-anywhere.herokuapp.com/" 7 8let parser = new RSSParser(); 9parser.parseURL(CORS_PROXY + 'https://www.reddit.com/.rss', function(err, feed) { 10 if (err) throw err; 11 console.log(feed.title); 12 feed.items.forEach(function(entry) { 13 console.log(entry.title + ':' + entry.link); 14 }) 15}) 16 17</script>
A few minor breaking changes were made in v3. Here's what you need to know:
new Parser()
before calling parseString
or parseURL
parseFile
is no longer available (for better browser support)options
are now passed to the Parser constructorparsed.feed
is now just feed
(top-level object removed)feed.entries
is now feed.items
(to better match RSS XML)Check out the full output format in test/output/reddit.json
1feedUrl: 'https://www.reddit.com/.rss' 2title: 'reddit: the front page of the internet' 3description: "" 4link: 'https://www.reddit.com/' 5items: 6 - title: 'The water is too deep, so he improvises' 7 link: 'https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/' 8 pubDate: 'Thu, 12 Nov 2015 21:16:39 +0000' 9 creator: "John Doe" 10 content: '<a href="http://example.com">this is a link</a> & <b>this is bold text</b>' 11 contentSnippet: 'this is a link & this is bold text' 12 guid: 'https://www.reddit.com/r/funny/comments/3skxqc/the_water_is_too_deep_so_he_improvises/' 13 categories: 14 - funny 15 isoDate: '2015-11-12T21:16:39.000Z'
contentSnippet
field strips out HTML tags and unescapes HTML entitiesdc:
prefix will be removed from all fieldsdc:date
and pubDate
will be available in ISO 8601 format as isoDate
author
is specified, but not dc:creator
, creator
will be set to author
(see article)updated
becomes lastBuildDate
for consistencyIf your RSS feed contains fields that aren't currently returned, you can access them using the customFields
option.
1let parser = new Parser({
2 customFields: {
3 feed: ['otherTitle', 'extendedDescription'],
4 item: ['coAuthor','subtitle'],
5 }
6});
7
8parser.parseURL('https://www.reddit.com/.rss', function(err, feed) {
9 console.log(feed.extendedDescription);
10
11 feed.items.forEach(function(entry) {
12 console.log(entry.coAuthor + ':' + entry.subtitle);
13 })
14})
To rename fields, you can pass in an array with two items, in the format [fromField, toField]
:
1let parser = new Parser({ 2 customFields: { 3 item: [ 4 ['dc:coAuthor', 'coAuthor'], 5 ] 6 } 7})
To pass additional flags, provide an object as the third array item. Currently there is one such flag:
keepArray (false)
- set to true
to return all values for fields that can have multiple entries.includeSnippet (false)
- set to true
to add an additional field, ${toField}Snippet
, with HTML stripped out1let parser = new Parser({ 2 customFields: { 3 item: [ 4 ['media:content', 'media:content', {keepArray: true}], 5 ] 6 } 7})
If your RSS Feed doesn't contain a <rss>
tag with a version
attribute,
you can pass a defaultRSS
option for the Parser to use:
1let parser = new Parser({
2 defaultRSS: 2.0
3});
rss-parser
uses xml2js
to parse XML. You can pass these options
to new xml2js.Parser()
by specifying options.xml2js
:
1let parser = new Parser({
2 xml2js: {
3 emptyTag: '--EMPTY--',
4 }
5});
You can set the amount of time (in milliseconds) to wait before the HTTP request times out (default 60 seconds):
1let parser = new Parser({
2 timeout: 1000,
3});
You can pass headers to the HTTP request:
1let parser = new Parser({
2 headers: {'User-Agent': 'something different'},
3});
By default, parseURL
will follow up to five redirects. You can change this
with options.maxRedirects
.
1let parser = new Parser({maxRedirects: 100});
rss-parser
uses http/https module
to do requests. You can pass these options
to http.get()
/https.get()
by specifying options.requestOptions
:
e.g. to allow unauthorized certificate
1let parser = new Parser({
2 requestOptions: {
3 rejectUnauthorized: false
4 }
5});
Contributions are welcome! If you are adding a feature or fixing a bug, please be sure to add a test case
The tests run the RSS parser for several sample RSS feeds in test/input
and outputs the resulting JSON into test/output
. If there are any changes to the output files the tests will fail.
To check if your changes affect the output of any test cases, run
npm test
To update the output files with your changes, run
WRITE_GOLDEN=true npm test
1npm run build 2git commit -a -m "Build distribution" 3npm version minor # or major/patch 4npm publish 5git push --follow-tags
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/16 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More