# @citation-js/plugin-csl

> Plugin for CSL output for Citation.js

Latest version **0.9.0** (published 2026-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @citation-js/plugin-csl
pnpm add @citation-js/plugin-csl
yarn add @citation-js/plugin-csl
bun add @citation-js/plugin-csl
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2026-09-18 |
| First published | 2018-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.12.0 |
| Dependencies | 2 |
| Unpacked size | 448.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 214 |
| Author | Lars Willighagen |
| Maintainers | larsgw |
| Keywords | citation-js, csl, citeproc |

## Links

- npm: https://www.npmjs.com/package/@citation-js/plugin-csl
- Repository: https://github.com/citation-js/citation-js
- Homepage: https://citation.js.org/
- Issues: https://github.com/citation-js/citation-js/issues
- npm.io page: https://npm.io/package/@citation-js/plugin-csl

## Dependencies (2)

- [citeproc](https://npm.io/package/citeproc.md) ^2.4.6
- [@citation-js/date](https://npm.io/package/@citation-js/date.md) ^0.5.0

## Recent versions

- 0.9.0 (latest) — 2026-09-18
- 0.8.2 — 2026-07-13
- 0.8.1 — 2026-07-05
- 0.8.0 — 2026-07-05
- 0.7.22 — 2025-12-31
- 0.7.21 — 2025-10-20
- 0.7.18 — 2025-01-28
- 0.7.14 — 2024-06-12
- 0.7.13 — 2024-06-06
- 0.7.11 — 2024-04-17
- 0.7.9 — 2024-03-05
- 0.7.6 — 2024-01-17
- 0.7.2 — 2023-10-14
- 0.7.1 — 2023-09-23
- 0.7.0 — 2023-09-23
- … 42 more at https://npm.io/package/@citation-js/plugin-csl/versions

## README

# @citation-js/plugin-csl
Plugin for CSL output for Citation.js. Output generation is done with [`citeproc-js`](https://github.com/Juris-M/citeproc-js).

[![NPM version](https://img.shields.io/npm/v/@citation-js/plugin-csl.svg)](https://npmjs.org/package/@citation-js/plugin-csl)
[![NPM total downloads](https://img.shields.io/npm/dt/@citation-js/plugin-csl.svg)](https://npmcharts.com/compare/@citation-js%2Fplugin-csl?minimal=true)
![License](https://img.shields.io/npm/l/@citation-js/plugin-csl.svg)
![Dependency status](https://img.shields.io/librariesio/release/npm/@citation-js/plugin-csl)
---

## Install

    npm install @citation-js/plugin-csl

## Usage

Register by importing the package:

```js
require('@citation-js/plugin-csl')
// or
import '@citation-js/plugin-csl'
```

## Formats

Formats and other features added by this plugin. General output options:

  * `style`: the style to use. Currently, the following are built-in:
    * `apa` (default)
    * `vancouver`
    * `harvard1`
  * `lang`: the locale to use. Currently, the following are built-in:
    * `en-US` (default)
    * `es-ES`
    * `de-DE`
    * `fr-FR`
    * `nl-NL`
  * `format`: output (markup) format used by `citeproc-js`
    * `text` (default)
    * `html`
    * `rtf`
    * `asciidoc`
    * `fo`
    * `latex`
  * `entry` (`String`, `Array[String]`): entry ID or list of entry IDs to identify the items to cite

### Bibliography

This plugin adds the output format `bibliography`, and accepts the following specific options:

  * `prepend` (`String`, `Function`): prepend static or dynamic text to each entry
  * `append` (`String`, `Function`): append static or dynamic text to each entry
  * `nosort` (`Boolean`, default: `false`): do not sort according to the style-defined rules
  * `asEntryArray` (`Boolean`, default: `false`): return an array of entries consisting of an id and the output for that individual entry

Here's an example for `prepend` and `append`:

```js
let cite = new Cite({ id: 'a', title: 'Item A' })

cite.format('bibliography', { append: ' [foobar]' })
// 'Item A. (n.d.). [foobar]\n'

cite.format('bibliography', { prepend (entry) { return `${entry.id}: ` } })
// 'a: Item A. (n.d.).\n'
```

And here's another example, possibly more realistic:

```js
let cite = new Cite('Q30000000')

let date = (new Date()).toLocaleDateString()

cite.format('bibliography', {
  format: 'html',
  style: 'apa',
  prepend (entry) {
    return `[${entry.id}]: `
  },
  append: ` [Retrieved on ${date}]`
})

// `<div class="csl-bib-body">
//   <div data-csl-entry-id="Q30000000" class="csl-entry">
//     [Q30000000]: Miccadei, S., De Leo, R., Zammarchi, E., Natali, P. G., &#38; Civitareale, D. (2002). The Synergistic Activity of Thyroid Transcription Factor 1 and Pax 8 Relies on the Promoter/Enhancer Interplay. <i>Molecular Endocrinology</i>, <i>16</i>(4), 837–846. https://doi.org/10.1210/MEND.16.4.0808 [Retrieved on 2018-7-10]
//   </div>
// </div>`
```

This prepends `[$ID]: ` to each entry, where `$ID` is the ID of that entry, and appends ` [Retrieved on $DATE]`, where `$DATE` is today (constant for all entries).

Here's an example for `asEntryArray`:

```js
const cite = new Cite([
  { id: 'a', title: 'Item A', issued: { literal: 2021 } },
  { id: 'b', title: 'Item B', issued: { literal: 2021 } }
])

cite.format('bibliography', { asEntryArray: true })
// [
//   [
//     "a"
//     "Item A. (2021).\n"
//   ],
//   [
//     "b"
//     "Item B. (2021).\n"
//   ]
// ]
```

### Citation

Here's an example for `entry`:

```js
let cite = new Cite([
  { id: 'a', title: 'Item A', issued: { 'date-parts': [[2016]] } },
  { id: 'b', title: 'Item B', issued: { 'date-parts': [[2017]] } },
  { id: 'c', title: 'Item C', issued: { 'date-parts': [[2018]] } }
])

cite.format('citation')
// '(“Item A,” 2016; “Item B,” 2017; “Item C,” 2018)'

cite.format('citation', { entry: ['a', 'b'] })
// '(“Item A,” 2016; “Item B,” 2017)'

cite.format('citation', { entry: 'a' })
// '(“Item A,” 2016)'
```

### Configuration

It is possible to add different styles and locales.

```js
const { Cite, plugins } = require('@citation-js/core')
// or
import { Cite, plugins } from '@citation-js/core'
```

#### Styles

Different [CSL Styles](https://github.com/citation-style-language/styles) can be registered like this:

```js
let styleName = 'custom'
let style = '<?xml version="1.0" encoding="utf-8"?><style ...>...</style>' // The actual XML file

let config = plugins.config.get('@csl')
config.styles.add(styleName, style)

let example = new Cite(...)
example.format('bibliography', {
  format: 'html',
  style: styleName,
  lang: 'en-US'
})
```

#### Locales

Different [CSL Locales](https://github.com/citation-style-language/locales) can be registered like this:

```js
let language = 'en-GB'
let locale = '<?xml version="1.0" encoding="utf-8"?><locale ...>...</locale>' // The actual XML file

let config = plugins.config.get('@csl')
config.locales.add(language, locale)

let example = new Cite(...)
example.format('bibliography', {
  format: 'html',
  style: 'apa',
  lang: language
})
```

#### Engine

The configuration object also exposes an internal method to prepare a Citeproc engine with given data and configuration:

```js
let config = plugins.config.get('@csl')

let citeproc = plugins.engine(
  /* data: */ [{ ... }],
  /* style: */ 'apa',
  /* locale: */ 'en-US',
  /* format: */ 'html'
)

let sortedIds = citeproc.updateItems(/* ids: */ [...])
let makeBibliography = citeproc.makeBibliography()
```

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