Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
npm install citation-js



Please use citation-js/citation-js if possible.
| citation-js/citation-js | replaces | larsgw/citation.js |
|---|---|---|
| This repository contains the npm package @citation-js/core and several other components. || This repository contains the npm package citation-js that wraps the aforementioned components for backwards compatibility. |
---
- Install
- Getting Started
- CLI
- Cite
* Async
- Acknowledgements
On Node.js, install the package (citation-js) like this:
npm install citation-js
To install the CLI as a global command, do this:
npm install --global citation-js
Browser releases are available here. These define require and add citation-js as a module.
``html`
You can read a guide on how to get started, together with some tutorials and examples, here.
Run the CLI like this:
citation-js [options]
Options:
-h, --help output usage information
-V, --version output the version number
-i, --input
-u, --url
-t, --text
-o, --output
-R, --output-non-real Do not output the file in its mime type, but as a string
-f, --output-type
To use the Cite constructor, require() the module like this:
`js`
const Cite = require('citation-js')
For example, to get the bibliographical data of the Wikidata item wd:Q21972834, and then format it in HTML, English and APA:
`js
let example = new Cite('Q21972834')
let output = example.format('bibliography', {
format: 'html',
template: 'apa',
lang: 'en-US'
})
console.log(output)
`
To test this code, go to RunKit.
Use the async API (recommended for Wikidata, URL, and DOI input) like this:
`js
let example = await Cite.async('Q21972834')
let output = example.format('bibliography', {
format: 'html',
template: 'apa',
lang: 'en-US'
})
console.log(output)
`
> Cite.async()` also supports options as the second argument, and a callback function as last argument.