### Install jsonfeed-to-rss
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
Install the package using npm. This command is used to add the jsonfeed-to-rss library to your project's dependencies.
```bash
npm install jsonfeed-to-rss
```
--------------------------------
### Example JSON Feed Input
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
This is an example of the JSON Feed structure that can be converted to RSS. It includes metadata and a list of items.
```json
{
"version":"https://jsonfeed.org/version/1",
"title":"bret.io log",
"home_page_url":"https://jsonfeed-to-rss.netlify.com",
"feed_url":"https://jsonfeed-to-rss.netlify.com/snapshots/readme-feed.json",
"description": "A simple summary that describes the podcast. It can have a few sentences.\n\nIf there is more than one paragraph, it gets truncated in some contexts.",
"next_url":"https://jsonfeed-to-rss.netlify.com/snapshots/2017.json",
"icon":"https://jsonfeed-to-rss.netlify.com/icon-512x512.png",
"author":{
"name":"Bret Comnes",
"url":"https://bret.io",
"avatar":"https://gravatar.com/avatar/8d8b82740cb7ca994449cccd1dfdef5f?size=512"
},
"_itunes":{
"about":"https://github.com/bcomnes/jsonfeed-to-rss#itunes",
"owner": {
"email": "bcomnes@gmail.com"
},
"image": "https://jsonfeed-to-rss.netlify.com/icon-3000x3000.png",
"category": "Sports & Recreation",
"subcategory": "Outdoor"
},
"items":[
{
"date_published":"2018-04-07T20:48:02.000Z",
"content_html":"
Curam ad aut hactenus dentes cedere vigil \nNon Clitorio vertitur cavatur \nLorem markdownum edendi, non ad clamant solacia septem ambierantque. Scelus te\nmihi arcum fore nitidam; in dixit de simul.
",
"url":"https://jsonfeed-to-rss.netlify.com/a-url-to-a-post",
"id":"https://jsonfeed-to-rss.netlify.com/a-url-to-a-post-2018-04-07T20:48:02.000Z",
"image": "https://jsonfeed-to-rss.netlify.com/a-url-to-a-post/episode-3000x3000.png",
"_itunes": {
"episode": 12
},
"attachments":[
{
"url":"https://jsonfeed-to-rss.netlify.com/a-url-to-a-post/attatchment.mp4",
"mime_type":"audio/mpeg",
"title":"Hey this is a podcast episode",
"duration_in_seconds":12345,
"size_in_bytes":1234
}
]
}
]
}
```
--------------------------------
### Example RSS 2.0.11 Output
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
This is an example of the RSS 2.0.11 feed generated from the provided JSON Feed input. It includes channel information and item details.
```xml
bret.io log
https://jsonfeed-to-rss.netlify.com
A simple summary that describes the podcast. It can have a few sentences.
If there is more than one paragraph, it gets truncated in some contexts.
en-us
© 2018 Bret Comnes
Sat, 07 Apr 2018 20:48:02 GMT
Sports & Recreation
Outdoor
jsonfeed-to-rss 1.1.1 (https://github.com/bcomnes/jsonfeed-to-rss#readme)
http://www.rssboard.org/rss-specification
https://jsonfeed-to-rss.netlify.com/icon-512x512.png
https://jsonfeed-to-rss.netlify.com
bret.io log
Bret Comnes
A simple summary that describes the podcast. It can have a few sentences.
A simple summary that describes the podcast.
episodic
Bret Comnes
bcomnes@gmail.com
-
Curam ad aut hactenus dentes cedere vigil
https://jsonfeed-to-rss.netlify.com/a-url-to-a-post
Bret Comnes
Curam ad aut hactenus dentes cedere vigil
Non Clitorio vertitur cavatur
Lorem markdownum edendi, non ad clamant solacia septem ambierantque. Scelus te
mihi arcum fore nitidam; in dixit de simul.
Curam ad aut hactenus dentes cedere vigil
Non Clitorio vertitur cavatur
Lorem markdownum edendi, non ad clamant solacia septem ambierantque. Scelus te
mihi arcum fore nitidam; in dixit de simul.
]]>
https://jsonfeed-to-rss.netlify.com/a-url-to-a-post-2018-04-07T20:48:02.000Z
Sat, 07 Apr 2018 20:48:02 GMT
```
--------------------------------
### opts.itunes
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Enables or overrides iTunes podcast extension fields. Can be set to `true` to emit all available tags or an object to provide specific overrides.
```APIDOC
## `opts.itunes` — Enable or override iTunes podcast extension fields
When set to `true`, all available iTunes namespace tags are emitted. When set to an object, the object is deep-merged into the feed's `_itunes` extension before processing, allowing per-call overrides without mutating the original feed data.
### Parameters
- **itunes** (boolean | object) - Controls iTunes extension fields.
- If `true`, all available iTunes tags are included.
- If an object, its properties are merged into the feed's `_itunes` extension.
- `owner` (object): iTunes owner details (e.g., `{ email: 'bob@example.com' }`).
- `image` (string): URL for the podcast artwork.
- `category` (string): Primary podcast category.
- `subcategory` (string): Secondary podcast category.
- `explicit` (boolean): Indicates if the content is explicit.
- `type` (string): Type of podcast (e.g., 'serial', 'episodic').
- `block` (boolean): If true, prevents the feed from appearing in the iTunes Store.
### Example
```js
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Podcast',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
author: { name: 'Bob' },
items: [
{
id: 'https://example.com/ep10',
url: 'https://example.com/ep10',
title: 'Episode 10',
content_text: 'Show notes for episode 10.',
date_published: '2024-06-01T00:00:00Z',
attachments: [{ url: 'https://example.com/ep10.mp3', mime_type: 'audio/mpeg', size_in_bytes: 1024, duration_in_seconds: 1800 }]
}
]
}
// Override iTunes metadata at call time — does not mutate `feed`
const rss = jsonfeedToRSS(feed, {
itunes: {
owner: { email: 'bob@example.com' },
image: 'https://example.com/artwork.png',
category: 'Arts',
subcategory: 'Books',
explicit: false,
type: 'serial',
block: false
}
})
console.log(rss.includes('serial ')) // true
console.log(rss.includes('')) // true
console.log(rss.includes('no ')) // true
```
```
--------------------------------
### Add RSS scheduling hints with `skipHours` and `skipDays`
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Utilize `skipHours` and `skipDays` arrays to provide hints to feed aggregators about when to avoid polling the feed. These map directly to the RSS `` and `` elements.
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'Weekly Newsletter',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
items: []
}
const rss = jsonfeedToRSS(feed, {
skipHours: [0, 1, 2, 3, 4, 5, 6], // Skip midnight–6am UTC
skipDays: ['Saturday', 'Sunday'], // No updates on weekends
ttl: 1440 // Cache for 24 hours
})
// Output includes:
// 0 1 ...
// Saturday Sunday
// 1440
console.log(rss.includes('')) // true
```
--------------------------------
### Enable and override iTunes podcast extensions
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Use the `itunes` option to enable iTunes podcast tags or provide an object to deep-merge and override specific iTunes metadata at call time. This does not mutate the original feed data.
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Podcast',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
author: { name: 'Bob' },
items: [
{
id: 'https://example.com/ep10',
url: 'https://example.com/ep10',
title: 'Episode 10',
content_text: 'Show notes for episode 10.',
date_published: '2024-06-01T00:00:00Z',
attachments: [{ url: 'https://example.com/ep10.mp3', mime_type: 'audio/mpeg', size_in_bytes: 1024, duration_in_seconds: 1800 }]
}
]
}
// Override iTunes metadata at call time — does not mutate `feed`
const rss = jsonfeedToRSS(feed, {
itunes: {
owner: { email: 'bob@example.com' },
image: 'https://example.com/artwork.png',
category: 'Arts',
subcategory: 'Books',
explicit: false,
type: 'serial',
block: false
}
})
console.log(rss.includes('serial ')) // true
console.log(rss.includes('')) // true
console.log(rss.includes('no ')) // true
```
--------------------------------
### opts.skipHours / opts.skipDays
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Arrays that provide scheduling hints to feed aggregators, specifying hours or days to skip polling the feed. These map directly to the RSS `` and `` elements.
```APIDOC
## `opts.skipHours` / `opts.skipDays` — RSS scheduling hints
Arrays that hint to feed aggregators which hours of the day or days of the week to skip polling the feed. Maps directly to the RSS `` and `` elements.
### Parameters
- **skipHours** (array of numbers, optional) - An array of hours (0-23) to skip.
- **skipDays** (array of strings, optional) - An array of days (e.g., 'Sunday', 'Monday') to skip.
- **ttl** (number, optional) - Time To Live in minutes, indicating how long the feed can be cached.
### Example
```js
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'Weekly Newsletter',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
items: []
}
const rss = jsonfeedToRSS(feed, {
skipHours: [0, 1, 2, 3, 4, 5, 6], // Skip midnight–6am UTC
skipDays: ['Saturday', 'Sunday'], // No updates on weekends
ttl: 1440 // Cache for 24 hours
})
// Output includes:
// 0 1 ...
// Saturday Sunday
// 1440
console.log(rss.includes('')) // true
```
```
--------------------------------
### RSS Feed Structure with Podcast Tags
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
This snippet demonstrates the structure of an RSS feed generated by the converter, including common podcast metadata tags like enclosure, episodeType, title, author, episode, subtitle, summary, image, and duration.
```xml
full
Curam ad aut hactenus dentes cedere vigil
Bret Comnes
12
Curam ad aut hactenus dentes cedere vigil
Curam ad aut hactenus dentes cedere vigil
https://jsonfeed-to-rss.netlify.com/a-url-to-a-post/episode-3000x3000.png
3:25:45
```
--------------------------------
### JSONFeed to RSS Conversion Options
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
Configuration options for the `jsonfeedToRSS` function. Customize feed URL, language, copyright, editor/webmaster details, ID handling, categories, TTL, skip hours/days, and iTunes extensions.
```javascript
{
// a function that returns the rss feed url
feedURLFn: (feedURL, jf) => feedURL.replace(/\.json\b/, '-rss.xml'),
language: 'en-us',
copyright: `© ${now.getFullYear()} ${jf.author && jf.author.name ? jf.author.name : ''}`,
managingEditor,
webMaster,
idIsPermalink: false, // if guid is the permalink, you can set this true
category, // array of categories.. will attempt to use iTunes categories if available
ttl,
skipHours,
skipDays,
itunes: !!jf._itunes // generate RSS feed with iTunes extensions
}
```
--------------------------------
### Customize RSS feed URL with `feedURLFn`
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Provide a `feedURLFn` function to customize how the JSON feed URL is transformed into the RSS feed URL. This affects the `` and `` tags.
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Site',
home_page_url: 'https://example.com',
feed_url: 'https://cdn.example.com/feeds/main.json',
items: []
}
// Place the RSS feed at a completely different URL
const rss = jsonfeedToRSS(feed, {
feedURLFn: (jsonFeedURL, jf) => `https://feeds.example.com/${jf.title.toLowerCase().replace(/\s+/g, '-')}.xml`
})
// The will point to: https://feeds.example.com/my-site.xml
console.log(rss.includes('feeds.example.com/my-site.xml')) // true
```
--------------------------------
### opts.feedURLFn
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
A function to customize how the JSON feed URL is transformed into the RSS feed URL. This is used for the `` and `` tags.
```APIDOC
## `opts.feedURLFn` — Custom RSS feed URL derivation
A function controlling how the JSON feed URL is transformed into the RSS feed URL. By default, `.json` is replaced with `-rss.xml`. This URL is written into the `` tag and the optional `` tag.
### Parameters
- **feedURLFn** (function) - A function that takes the JSON feed URL and the original JSON feed object as arguments and returns the desired RSS feed URL.
- `jsonFeedURL` (string): The original URL of the JSON feed.
- `jf` (object): The parsed JSON feed object.
### Example
```js
const jsonfeedToRSS = require('jsonfeed-to-rss')
const feed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Site',
home_page_url: 'https://example.com',
feed_url: 'https://cdn.example.com/feeds/main.json',
items: []
}
// Place the RSS feed at a completely different URL
const rss = jsonfeedToRSS(feed, {
feedURLFn: (jsonFeedURL, jf) => `https://feeds.example.com/${jf.title.toLowerCase().replace(/\s+/g, '-')}.xml`
})
// The will point to: https://feeds.example.com/my-site.xml
console.log(rss.includes('feeds.example.com/my-site.xml')) // true
```
```
--------------------------------
### Convert JSON Feed to RSS
Source: https://github.com/bcomnes/jsonfeed-to-rss/blob/master/README.md
Import the library and use the `jsonfeedToRSS` function with your JSON Feed data. The function returns an RSS 2.0.11 formatted string.
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const someJSONFeed = require('./load-some-json-feed-data.json')
const rssFeed = jsonfeedToRSS(someJSONFeed) // Returns an rss 2.0.11 formatted json feed
```
--------------------------------
### jsonfeedToRSS(parsedJsonfeed, opts)
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Converts a parsed JSON feed object into an RSS 2.0.11 XML string. It supports various options for customization and handles common syndication extensions like iTunes and Dublin Core. The function throws an error if essential feed properties are missing.
```APIDOC
## jsonfeedToRSS(parsedJsonfeed, opts)
### Description
Converts a JSON feed object to an RSS 2.0.11 XML string. Accepts a parsed JSON feed object and an optional options object. Returns a pretty-printed RSS XML string. Throws if required fields (`title`, `feed_url`, `home_page_url`, `version`) are missing. iTunes extensions are automatically enabled when the feed contains a `_itunes` top-level property, or can be forced via `opts.itunes`.
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **parsedJsonfeed** (object) - Required - A parsed JSON feed object conforming to https://jsonfeed.org/version/1.
- **opts** (object) - Optional - An options object for customization.
- **feedURLFn** (function) - Optional - A function to transform the JSON feed URL into the RSS feed URL.
- **language** (string) - Optional - The language of the feed (e.g., 'en-us').
- **copyright** (string) - Optional - Copyright information for the feed.
- **managingEditor** (string) - Optional - The email address of the managing editor.
- **idIsPermalink** (boolean) - Optional - Determines if item IDs should be treated as permalinks.
- **ttl** (number) - Optional - The time-to-live for the feed in minutes.
### Request Example
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const jsonFeed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Podcast',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
description: 'A podcast about interesting things.',
author: { name: 'Jane Doe', url: 'https://example.com' },
icon: 'https://example.com/icon-512.png',
_itunes: {
owner: { email: 'jane@example.com' },
image: 'https://example.com/artwork-3000.png',
category: 'Technology',
subcategory: 'Tech News',
explicit: false,
type: 'episodic'
},
items: [
{
id: 'https://example.com/ep1',
url: 'https://example.com/ep1',
title: 'Episode 1: Getting Started',
content_html: 'Welcome to the show!
',
content_text: 'Welcome to the show!',
date_published: '2024-01-15T10:00:00Z',
image: 'https://example.com/ep1-art.png',
_itunes: { episode: 1 },
attachments: [
{
url: 'https://example.com/ep1.mp3',
mime_type: 'audio/mpeg',
size_in_bytes: 52428800,
duration_in_seconds: 3600
}
]
}
]
}
const opts = {
feedURLFn: (feedURL, jf) => feedURL.replace(/\.json$/, '-rss.xml'),
language: 'en-us',
copyright: '© 2024 Jane Doe',
managingEditor: 'jane@example.com (Jane Doe)',
idIsPermalink: false,
ttl: 60
}
try {
const rssFeed = jsonfeedToRSS(jsonFeed, opts)
console.log(rssFeed)
} catch (err) {
console.error('Feed conversion failed:', err.message)
}
```
### Response
#### Success Response (200)
- **rssFeed** (string) - A well-formed RSS 2.0.11 XML string.
#### Response Example
```xml
My Podcast
https://example.com
...
-
Episode 1: Getting Started
1:00:00
...
```
### Error Handling
- **Missing Required Fields**: Throws an error if `title`, `feed_url`, `home_page_url`, or `version` are absent in the `parsedJsonfeed` object.
```
--------------------------------
### jsonfeedToRSSObject(parsedJsonfeed, opts)
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Converts a JSON feed object into an intermediate RSS JavaScript object. This is useful for inspecting or modifying the RSS structure before it's serialized to XML.
```APIDOC
## `jsonfeedToRSSObject(parsedJsonfeed, opts)` — Convert a JSON feed to an intermediate RSS JavaScript object
The lower-level export (`require('jsonfeed-to-rss/jsonfeed-to-rss-object')`). Returns the plain JavaScript object that represents the RSS feed structure before it is serialized to XML by `xmlbuilder`. Useful for inspecting or modifying the RSS structure programmatically before rendering.
### Parameters
- **parsedJsonfeed** (object) - The parsed JSON feed object.
- **opts** (object, optional) - Options for the conversion.
### Returns
- (object) - A plain JavaScript object representing the RSS feed structure.
### Example
```js
const jsonfeedToRSSObject = require('./jsonfeed-to-rss-object')
const jsonFeed = {
version: 'https://jsonfeed.org/version/1',
title: 'Tech Blog',
home_page_url: 'https://blog.example.com',
feed_url: 'https://blog.example.com/feed.json',
author: { name: 'Alice' },
items: [
{
id: 'https://blog.example.com/post-1',
url: 'https://blog.example.com/post-1',
title: 'Hello World',
content_html: 'First post.
',
date_published: '2024-03-01T09:00:00Z',
tags: ['intro', 'welcome']
}
]
}
const rssObj = jsonfeedToRSSObject(jsonFeed)
// rssObj is a plain JS object like:
// {
// rss: {
// '@version': '2.0',
// '@xmlns:atom': 'http://www.w3.org/2005/Atom',
// channel: {
// title: 'Tech Blog',
// link: 'https://blog.example.com',
// item: [{ title: 'Hello World', category: ['intro', 'welcome'], ... }]
// }
// }
// }
// Inject a custom field before serializing
rssObj.rss.channel['custom:field'] = 'extra metadata'
// Serialize manually if needed
const builder = require('xmlbuilder')
const xml = builder.create(rssObj, { encoding: 'utf-8', skipNullNodes: true })
console.log(xml.end({ pretty: true }))
```
```
--------------------------------
### Convert JSON feed to RSS JavaScript object
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Use `jsonfeedToRSSObject` for programmatic access to the intermediate RSS object before XML serialization. This allows for inspection or modification of the RSS structure.
```javascript
const jsonfeedToRSSObject = require('./jsonfeed-to-rss-object')
const jsonFeed = {
version: 'https://jsonfeed.org/version/1',
title: 'Tech Blog',
home_page_url: 'https://blog.example.com',
feed_url: 'https://blog.example.com/feed.json',
author: { name: 'Alice' },
items: [
{
id: 'https://blog.example.com/post-1',
url: 'https://blog.example.com/post-1',
title: 'Hello World',
content_html: 'First post.
',
date_published: '2024-03-01T09:00:00Z',
tags: ['intro', 'welcome']
}
]
}
const rssObj = jsonfeedToRSSObject(jsonFeed)
// rssObj is a plain JS object like:
// {
// rss: {
// '@version': '2.0',
// '@xmlns:atom': 'http://www.w3.org/2005/Atom',
// channel: {
// title: 'Tech Blog',
// link: 'https://blog.example.com',
// item: [{ title: 'Hello World', category: ['intro', 'welcome'], ... }]
// }
// }
// }
// Inject a custom field before serializing
rssObj.rss.channel['custom:field'] = 'extra metadata'
// Serialize manually if needed
const builder = require('xmlbuilder')
const xml = builder.create(rssObj, { encoding: 'utf-8', skipNullNodes: true })
console.log(xml.end({ pretty: true }))
```
--------------------------------
### Convert JSON Feed to RSS XML
Source: https://context7.com/bcomnes/jsonfeed-to-rss/llms.txt
Use the `jsonfeedToRSS` function to convert a parsed JSON feed object into an RSS 2.0.11 XML string. This function supports various options for customization and automatically handles common extensions. Ensure required fields are present in the JSON feed object to avoid errors.
```javascript
const jsonfeedToRSS = require('jsonfeed-to-rss')
const jsonFeed = {
version: 'https://jsonfeed.org/version/1',
title: 'My Podcast',
home_page_url: 'https://example.com',
feed_url: 'https://example.com/feed.json',
description: 'A podcast about interesting things.',
author: { name: 'Jane Doe', url: 'https://example.com' },
icon: 'https://example.com/icon-512.png',
_itunes: {
owner: { email: 'jane@example.com' },
image: 'https://example.com/artwork-3000.png',
category: 'Technology',
subcategory: 'Tech News',
explicit: false,
type: 'episodic'
},
items: [
{
id: 'https://example.com/ep1',
url: 'https://example.com/ep1',
title: 'Episode 1: Getting Started',
content_html: 'Welcome to the show!
',
content_text: 'Welcome to the show!',
date_published: '2024-01-15T10:00:00Z',
image: 'https://example.com/ep1-art.png',
_itunes: { episode: 1 },
attachments: [
{
url: 'https://example.com/ep1.mp3',
mime_type: 'audio/mpeg',
size_in_bytes: 52428800,
duration_in_seconds: 3600
}
]
}
]
}
const opts = {
// Transform the JSON feed URL into the RSS feed URL
feedURLFn: (feedURL, jf) => feedURL.replace(/\.json$/, '-rss.xml'),
language: 'en-us',
copyright: '© 2024 Jane Doe',
managingEditor: 'jane@example.com (Jane Doe)',
idIsPermalink: false,
ttl: 60
}
try {
const rssFeed = jsonfeedToRSS(jsonFeed, opts)
console.log(rssFeed)
//
//
//
// My Podcast
// https://example.com
// ...
// -
//
Episode 1: Getting Started
//
// 1:00:00
// ...
//
//
//
} catch (err) {
console.error('Feed conversion failed:', err.message)
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.