A Simple and Robust JSON Parser and Generator for R

A reasonably fast JSON parser and generator, optimized for statistical data and the web. Offers simple, flexible tools for working with JSON in R, and is particularly powerful for building pipelines and interacting with a web API. The implementation is based on the mapping described in the vignette (Ooms, 2014). In addition to converting JSON data from/to R objects, 'jsonlite' contains functions to stream, validate, and prettify JSON data. The unit tests included with the package verify that all edge cases are encoded and decoded consistently for use with dynamic data in systems and applications.



  • Add parse_json() wrapper that does not guess if a string is actually a file/url
  • Fix a few rchk warnings (mostly false positives)
  • Add asJSON method for hms
  • Do not require is.vector() for unbox to support values with attributes e.g. factor or tzone
  • write_json now suppresses recoding of strings on windows, fixes #226
  • Hide internal libyajl symbols from shlib
  • Remove C calls R connection API which are no longer allowed on CRAN. This may lead to about 5% performance decrease for parsing from connections.
  • Remove depreacted rbind.pages function


  • Workaround for #180. fromJSON() first checks for literal json, then filename
  • Rename rbind.pages to rbind_pages to fix warning in R-devel (requested by CRAN)


  • Properly escape control characters \x01 through \x1f in toJSON()
  • Support parsing JSON prefixed with a rfc7464 ASCII Record Separator (0x1E)
  • (un)serializeJSON and do not set 'attributes' and 'value' for NULL anymore
  • serializeJSON() sets class="json" on output value, consistent with toJSON()
  • Rewrite (un)serializeJSON() for S4 classes and added some unit tests
  • Fix for simplyfing datelists, needed for mongolite


  • The solidus '/' is now escaped when preceded by '<' for safe html embedding (#163)
  • Code for reading from connections is ported to C.
  • Code for escaping strings has been rewritten
  • toJSON gains internal argument no_dots for needed by mongolite
  • Better support for parsing extjson date strings


  • Add 'read_json' and 'write_json' convenience wrappers
  • Update modp_numtoa from upstream (fixes a rounding issue in #148)
  • Ensure asJSON.POSIXt does not use sci notation for negative values (#155, John Greeley)
  • Tweak num_to_char to properly print large negative numbers
  • Performance optimization for simplyfing data frames


  • stream_in now passes ... arguments to fromJSON as documented
  • Force ANSI_STDIO on Windows to fix -pedantic compiler warning
  • Close connection even if opening fails. Fixes #145
  • validate() now includes an 'offset' attribute indicating at which byte the error occured
  • Refresh some example tokes for vignettes


  • Fix always_decimal for non-whole numbres which get rounded to whole numbers
  • Rename and export base64 encoder/decoder
  • Fix compiler warning on Windows: don't redefine isnan() and isinf()
  • Changed targed in Makevars to libstatyajl.a to prevent conflict with system libyajl
  • Bump to 1.0 because this package is basically done


  • Fix for side effects of 'always_decimal' on Date and POSIXt integer encoding
  • Fixed a small memory leak in the push parser (fromJSON.connection)
  • Cleaned up Makevars
  • Replace base64 encoder/decoder to be in-memory
  • Special case toJSON(NULL, null = "null") now returns "null"


  • Add 'always_decimal' argument in toJSON for real number notation in whole number doubles.


  • Performance optimization for toJSON on matrices and arrays
  • Tweak for unboxed POSIXt = "mongo" queries


  • Remove the View() workaround because it causes issues in RStudio and because the bug in utils::View has been fixed in R-patched.


  • Removed support for the archived int64 package. Use bit64 instead.
  • The stream_in function now skips over blank lines
  • Remove workaround for View() in rstudio
  • fromJSON now sets an 'Accept' request header for URLs.


  • Fix for 1 dimensional array objects
  • Fix for unnamed data frame
  • Fix for duplicate _row fields
  • The 'unbox' function now accepts classed scalars such as dates
  • Ignore BOM with warning in push parser


  • Performance optimizations in asJSON.data.frame by avoiding apply()
  • Prettifying is now done by default in R (thanks to Yihui Xie)
  • Add json_verbatim option to insert verbatim json
  • Improve verbose output of streaming functions


  • Replaced RCurl dependency with the new curl package.
  • Added push parser for more efficient parsing from connection interfaces (e.g. files or urls).
  • The toMongo function has been removed. Use stream_out instead.
  • The View function will not be exposed in recent versions of rstudio that supported nested data natively.
  • Add hidden bigint_as_char argument in fromJSON
  • Fixed a memory leak in fromJSON.
  • I() forces boxing of a scalar when 'auto_unbox = TRUE' for RJSONIO compatibility.
  • toJSON now supports 'keep_vec_names=TRUE' will mimic RJSONIO legacy behavior.
  • toJSON now supports 'time_format' argument to customize formatting of POSIXt strings.


  • Change license to MIT (for GPL2 compatibility).
  • Add support for digits = I(n) to use significant precision.
  • When 'pretty' in toJSON is numeric, it specifies the number of spaces to indent.
  • Bug fix in validate() related to ScalarLogical
  • Add support for dataframe = "values"
  • Byte-order-marks are now ignored as suggested by rfc7159
  • Add support for integer64 class (bit64 package)


  • Ported some number formatting to C
  • Fix when http server gives no content-type header
  • Prevent auto unboxing within a matrix
  • Assume UTF8 but fall back on native encoding for files and urls in fromJSON
  • Fix for 32 bit windows XP.


  • New JSON parser based on yajl. Some changes:
    • smaller and faster than libjson
    • better error messages
    • automatic validation
    • native \uXXXX unicode parsing
    • integer parsing
    • uses spaces intead of tabs for prettify
  • Other functions ported to C: collapse_object, null_to_na, is_recordlist, is_scalarlist
  • Expose 'flatten' function
  • Row names are encoded as "_row" instead of "$row"
  • Start with streaming functions
  • Some internal changes to support BSON/MongoDB


  • Added toJSON null argument
  • Fix bug in prettify object name escaping
  • Use C code for escaping and collapsing vectors
  • Several performance enhancements in fromJSON/simplify code
  • The auto_unbox argument is ignored for dataframes when dataframe="column"


  • Add support for escaped (hexadecimal) unicode characters in fromJSON(unicode = TRUE)
  • Exporting a wrapper for View() that flattens nested data frames
  • Add print method for scalar (unbox)


  • Fix bug where 'flatten' argument wasn't passed down
  • Make asJSON automatically unname any named lists within a data frame
  • fromJSON(url) now sets Accept header
  • Increase default to digits=4 in toJSON


  • Remove whitespace from default output of toJSON
  • Split vignette in 3 documents
  • Add support for simplifyMatrix within a data frame
  • Add class "json" output of toJSON, simplify, minify
  • Add print method for json
  • Cleaned up unit tests
  • Workaround for SSL handshake issues in https downloads
  • Raise warnings for SSL or Content-Type abnormalities


  • formally expose 'force' argument in toJSON
  • formally expose 'flatten' argument in fromJSON
  • fix bug in simplifyDataframe
  • fix in rlibjson code that converted empty array to AsIs object
  • auto coerse mongo type dates in fromJSON


  • toJSON gains argument auto_unbox
  • Minor fixes


  • Never raise error in toJSON when force=true
  • Fix typo in line 2 of JSONDefs/GNU_C.h (GUN -> GNU)
  • Run unit tests during R CMD check
  • Update vignette


  • Added minify function
  • Added unbox function
  • Fixed bug where toJSON 'force' argument wasn't passed down
  • Removed -DJSON_VALIDATE -DJSON_STREAM=1 from Makevars.in (already in JSONoptions.h)


  • Changes by Prof Ripley for Solaris/CRAN


  • Update libjson to 7.6.1 (fixes bug in the validator)
  • Generalized toJSON method 'matrix' to 'array' to work for higher dimensions.
  • Add option to encode matrix either row-major or column-major.
  • Set default SSL version to 3 for fromJSON("https://...")


  • Major performance improvements for toJSON.data.frame


  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.7.3 by Jeroen Ooms, 12 days ago

https://arxiv.org/abs/1403.2805 (paper)

Report a bug at https://github.com/jeroen/jsonlite/issues

Browse source code at https://github.com/cran/jsonlite

Authors: Jeroen Ooms [aut, cre] , Duncan Temple Lang [ctb] , Lloyd Hilaiel [cph] (author of bundled libyajl)

Documentation:   PDF Manual  

Task views: Web Technologies and Services

MIT + file LICENSE license

Depends on methods

Suggests httr, curl, vctrs, testthat, knitr, rmarkdown, R.rsp, sf

Imported by AWR.KMS, AWR.Kinesis, AirSensor, AutoDeskR, AzureAppInsights, AzureAuth, AzureCognitive, AzureCosmosR, AzureGraph, AzureKeyVault, AzureKusto, AzureRMR, AzureTableStor, AzureVM, BARIS, BENMMI, BFS, BIOMASS, BioCircos, BoSSA, BrownDog, CEDARS, CNAIM, CSGo, Cluster.OBeu, CytobankAPI, DEPONS2R, DQAstats, DT, DTAT, DataSpaceR, DatastreamDSWS2R, DemografixeR, DescriptiveStats.OBeu, DockerParallel, ECharts2Shiny, EML, EventStudy, FlickrAPI, GADMTools, GNRS, GRANBase, GetBCBData, GetQuandlData, HARtools, IMFData, IRkernel, InflectSSP, IsoplotRgui, JBrowseR, JamendoR, JirAgileR, Knoema, MODISTools, MODIStsp, ManagedCloudProvider, MazamaLocationUtils, MetaDBparse, Microsoft365R, Morpho, NSO1212, ODataQuery, OmicNavigator, OpenML, PTXQC, PWFSLSmoke, ParallelLogger, Platypus, PxWebApiData, QBMS, Quandl, R2019nCoV, RAMClustR, RAQSAPI, RBitmoji, RColetum, RCzechia, RDataCanvas, RDota2, RGA, RGeckoboard, RInno, RKorAPClient, RMixpanel, ROpenDota, ROpenFIGI, ROpenWeatherMap, RPresto, RPublica, RPushbullet, RSBJson, RSiteCatalyst, RSocrata, RStripe, RTD, RTL, RTTWebClient, RYandexTranslate, RZabbix, Rcrawler, ReDaMoR, RefManageR, RestRserve, ReviewR, Rexperigen, Rga4gh, Rnvd3, RobinHood, RonFHIR, Rspotify, RtD3, Rwtss, SACCR, SAR, SC2API, SDMtune, SGP, SMITIDvisu, SP2000, SPOTMisc, SUNGEO, SWTools, SensusR, Seurat, SigOptR, SignacX, SmarterPoland, TCIApathfinder, TKCat, TargomoR, Tejapi, TexExamRandomizer, ThankYouStars, TidyMultiqc, TimeSeries.OBeu, TooManyCellsR, Twitmo, TwitterAutomatedTrading, UCSCXenaTools, V8, WebGestaltR, WikidataQueryServiceR, WikidataR, WikipediR, WufooR, XKCDdata, XR, Zelig, abstr, academictwitteR, acled.api, acumos, adepro, adobeanalyticsr, adsDataHubR, aiRly, alfr, alfred, algo, allcontributors, alphavantager, altadata, altfuelr, amapGeocode, ambiorix, analogsea, aniview, antaresRead, aos, apexcharter, appler, apsimx, arakno, archiveRetriever, archivist.github, arcpullr, arenar, argparse, ariExtra, asciicast, atom4R, aurelius, aurin, ausplotsR, available, aws.comprehend, aws.ec2metadata, aws.iam, aws.kms, aws.lambda, aws.polly, aws.transcribe, aws.translate, bRacatus, batata, bcdata, bcmaps, bdl, bea.R, beakr, bender, bigQueryR, bigrquery, billboarder, binancer, binman, biocompute, biomartr, bitmexr, bizdays, blastula, blogdown, blsR, bold, boxr, brandwatchR, briqr, bs4Dash, bslib, bsplus, bysykkel, c3, caRecall, calpassapi, canadacovid, cancensus, cansim, canvasXpress, captr, catSurv, cbsodataR, ccmReportR, cdcfluview, cdrcR, censusapi, censys, cfbfastR, cffr, checkpoint, chessR, childesr, chillR, chirps, cimir, circle, citation, citationchaser, citecorp, civis, ckanr, clarifai, climaemet, clinDataReview, cloudml, cloudos, coalitions, codebook, codemeta, codemetar, cognitoR, coinmarketcapr, collidr, colourlovers, colourpicker, cometr, comtradr, concaveman, configr, connectwidgets, covr, cpsR, cqcr, cranlogs, credentials, crosstalk, crossword.r, crul, crunch, crypto2, cryptowatchR, csodata, csvwr, csvy, ctf, cthist, ctrdata, cumulocityr, cwbtools, cyclestreets, czso, d4storagehub4R, daff, dagitty, daiR, dash, data360r, dataRetrieval, datadigest, dataone, datapackage.r, datarobot, dataspice, dataverse, datoramar, deckgl, deepdep, devtoolbox, dextergui, diezeit, diffviewer, dimensionsR, dipsaus, disastr.api, discgolf, disk.frame, distcomp, distill, dkanr, dlstats, dockerfiler, docuSignr, dpmr, duckduckr, dynatopGIS, ebirdst, echarts4r, echarty, edgarWebR, educationdata, eia, eiopaR, elastic, elevatr, emld, emuR, epidata, epigraphdb, epitweetr, epwshiftr, esquisse, ether, etrader, europepmc, eurostat, exCon, excelR, exifr, exiftoolr, ezpickr, facerec, factset.analyticsapi.engines, faq, fastRhockey, faux, fbRads, federalregister, fedstatAPIr, fflr, ffmetadata, ffscrapr, finbif, fipe, firebase, fishtree, fitbitScraper, fitbitViz, fitbitr, fitzRoy, fixerapi, flashCard, flexdashboard, flipdownr, flora, fmpcloudr, foghorn, fomantic.plus, foreSIGHT, franc, fredr, frostr, ftExtra, fusionchartsR, g3viz, galah, galvanizer, ganalytics, gargle, gbfs, gdalcubes, gde, gdns, geckor, gender, genderBR, genesysr, geojson, geojsonio, geojsonlint, geomedb, geometa, getMet, gethr, geysertimes, gfer, gfonts, ggimage, ggvis, gh, ghee, ghql, gistr, gitear, gitgadget, githubinstall, gitignore, gkgraphR, gmailr, golem, goodpractice, googleAnalyticsR, googleAuthR, googleCloudRunner, googleCloudStorageR, googleCloudVisionR, googleComputeEngineR, googleLanguageR, googlePrintr, googleTagManageR, googleVis, googledrive, googlenlp, googler, googlesheets, googleway, gotop, gprofiler2, gqlr, gradeR, gradientPickerD3, graphhopper, graphql, gridSVG, gtrendsR, guardianapi, gwasrapidd, gwavr, gym, h2o, hackeRnews, handlr, hansard, helsinki, hereR, highcharter, hlidacr, hoopR, htmlwidgets, httping, httptest, httptest2, httr, hydroscoper, hypothesisr, iCellR, ibb, ibmAcousticR, ibmsunburst, icesTAF, ichimoku, idbr, iheatmapr, imfr, imgrec, immunarch, inegiR, influxdbclient, influxdbr, intensegRid, ip2location, ip2proxy, isoWater, istacr, jaod, jinjar, jmvcore, jose, jrc, jsTree, json64, jsonld, jsonstat, jsontools, keyToEnglish, keys, kibior, kiwisR, klassR, klustR, kntnr, lacrmr, lambdr, languagelayeR, languageserver, lares, leafletCN, leafletR, leafpm, leanpubr, learnr, legco, leprechaun, lifx, lightgbm, liminal, limonaid, lingtypology, lintr, livechatR, magmaR, majesticR, manifestoR, mapboxapi, mapedit, mapping, mapr, matahari, measurementProtocol, mediacloudr, medrxivr, meteospain, metro, micar, microdemic, miniMeta, mitre, mlflow, mlr3oml, mnis, modchart, modelStudio, moexer, mongolite, mongopipe, mortyr, mregions, mscstexta4r, mscstts, mscsweblm4r, msig, mstrio, mudata2, nCov2019, nasadata, nasapower, natserv, ndtv, neo2R, neo4r, neonUtilities, neotoma, netgsa, nettskjemar, newsanchor, nfl4th, nhdplusTools, nhlapi, nhlscrape, njgeo, nmadb, noaaoceans, nodbi, nominatimlite, nomisr, norgeo, nse2r, nser, nsrr, nzilbb.labbcat, ocs4R, odin, oncrawlR, onelogin, onepass, onsr, opalr, openadds, opencage, opencpu, opendotaR, openeo, osfr, osmdata, osmextract, osrm, otpr, outsider, owdbr, owidR, owmr, oxcAAR, oxcgrt, oysteR, packagefinder, packer, pagedown, pageviews, paleotree, pandocfilters, pangaear, patentsview, pathlit, paws.common, pbixr, pcatsAPIclientR, pda, pdfetch, pdfminer, peRspective, pedquant, peermodels, pestr, phenocamr, piggyback, pinnacle.API, pins, pkgcache, pkgdepends, pkgdown, pkgsearch, plotly, plumber, plumberDeploy, plumbertableau, pluscode, pocketapi, polished, polmineR, postGIStools, postlightmercury, povcalnetR, ppcong, preregr, previsionio, priceR, promote, protolite, provDebugR, provParseR, ptm, ptvapi, pushbar, pxweb, qiitr, qrandom, qtl2, qualtRics, quarto, r.proxy, r2d3, rAltmetric, rAmCharts4, rDataPipeline, rIP, rRofex, rTorch, rWBclimate, radiant.data, rameritrade, randNames, randquotes, rangeModelMetadata, rapiclient, rapidoc, rapsimng, rarms, raveio, ravelRy, rbcb, rbhl, rbioapi, rbison, rbokeh, rchie, rcites, rcitoid, rcol, rcoreoa, rcorpora, rcrossref, rdatacite, rdbnomics, rdhs, rdomains, rdrop2, rdryad, rdtLite, reactable, reactlog, readbulk, readit, readtext, rebird, rechonest, recogito, red, redoc, refuge, rehydratoR, rentrez, repec, repr, reproducer, reqres, request, rerddap, reticulate, reutils, reveneraR, revulyticsR, rfacebookstat, rfieldclimate, rfishbase, rfishdraw, rgbif, rgee, rgl, rgnparser, rgoogleads, rgoogleslides, rgtmx, rgugik, rhandsontable, rhub, rhymer, ricu, ridigbio, riem, riingo, rinat, rintrojs, ritis, rjstat, rlc, rlist, rmangal, rmapshaper, rmapzen, rmarkdown, rnassqs, rnbp, rnoaa, rnpn, rnrfa, roadoi, robis, robservable, rockr, rolldown, ropendata, rorcid, rosetteApi, rotl, rphylopic, rplos, rpredictit, rredlist, rrefine, rsconnect, rscopus, rscorecard, rsinaica, rsleep, rsnps, rstac, rstatscn, rstoat, rstudio.prefs, rtrek, rtry, rtweet, rtypeform, rvertnet, rvkstat, rwebstat, ryandexdirect, rzentra, safetyGraphics, salesforcer, sbtools, scrobbler, sdcHierarchies, secret, seeclickfixr, semnar, sen2r, sendgridr, sensibo.sky, sentryR, sergeant, servr, sfarrow, shidashi, shiny, shiny.i18n, shiny.react, shiny.semantic, shinyAce, shinyChakraUI, shinyFeedback, shinyFiles, shinyGovstyle, shinyMatrix, shinyMobile, shinySearchbar, shinyTree, shinyWidgets, shinybootstrap2, shinybusy, shinyfullscreen, shinyjqui, shinyjs, shinyloadtest, shinylogs, shinymaterial, shinypanel, shinyscreenshot, shinysurveys, shinytest, shopifyr, shutterstock, siebanxicor, sigmaNet, sigmajs, simrel, sismonr, sketch, skilljaR, slackr, sleepwalk, socialmixr, sofa, solrium, solvebio, sonicscrewdriver, sortable, spacey, spant, sparklyr, sparklyr.nested, spectralAnalysis, spectrino, spidR, splashr, spocc, spotifyr, srcr, sship, standartox, statnipokladna, statsearchanalyticsr, statswalesr, stevedore, stmCorrViz, storywranglr, stplanr, studentlife, subscreen, suppdata, swissparl, tableschema.r, taxa, taxadb, taxize, tcsinvest, teamr, telegram, telegram.bot, testthat, tfdeploy, tfruns, threeBrain, threesixtygiving, tidyRSS, tidyUSDA, tidycensus, tidycwl, tidygeoRSS, tidygeocoder, tidyjson, tidyquant, tidyqwi, tidystats, tidytuesdayR, tidyverse, tidywikidatar, timevis, tinyscholar, tinyspotifyr, tippy, tm1r, togglr, tomba, tracerer, trackeR, traits, trelliscopejs, trelloR, tremendousr, trustedtimestamping, tuber, tubern, twfy, twilio, uavRmp, uklr, ukpolice, uptasticsearch, urlshorteneR, usdampr, usdarnass, usethis, vagalumeR, valhallr, vaultr, vegalite, vegawidget, vetiver, vfinputs, viafr, visNetwork, vitae, vkR, vmr, voson.tcn, vosonSML, voteogram, votesmart, vstsr, wallace, wbstats, wdnr.gis, webTRISr, webchem, webdriver, webexercises, webmockr, webshot, webtools, webutils, wehoop, wellknown, whereami, whoami, wiesbaden, wikitaxa, wildviz, windsoraiR, worldfootballR, worrms, wosr, x.ent, xgboost, yhatr, yummlyr, zbank, zdeskR, zen4R, zipcodeR, zoltr, zzlite.

Depended on by GoogleKnowledgeGraphR, RGoogleAnalyticsPremium, RGoogleFit, RSauceLabs, RWildbook, Rlabkey, TMDb, condusco, cyjShiny, dictionaRy, eFRED, hystReet, instaR, jSonarR, kofdata, nitrcbot, openblender, rHealthDataGov, rgdax, seleniumPipes, timeseriesdb, webglobe.

Suggested by AzureStor, ChemoSpec, ComplexUpset, DataExplorer, Gmisc, MoBPS, PetfindeR, RAthena, RagGrid, Rpoet, TextMiningGUI, auditor, azuremlsdk, basictabler, bench, bookdown, conos, cowsay, crosstable, curl, d3r, dashCoreComponents, dashPivottable, data.tree, datadogr, datamods, dbx, dccvalidator, denvax, designr, dismo, distribglm, divest, dodgr, downlit, ecmwfr, fbar, finch, funchir, futile.logger, gap, geodata, getable, googlePubsubR, httr2, iBreakDown, iNZightPlots, iNZightTools, ingredients, io, isotree, jab.adverse.reactions, jqr, jsTreeR, jsonvalidate, justifier, kgschart, leaflet.extras, leaflet.extras2, leaflet.providers, lgr, lgrExtra, listviewer, log4r, logger, magick, mapdeck, matchbook, metamicrobiomeR, metricsgraphics, microservices, mockthat, naaccr, ncdfgeom, neonstore, networkD3, nflfastR, noctua, openssl, orderly, pak, passport, pense, pivottabler, pointblank, presser, qtlcharts, quanteda, quantmod, rAmCharts, rdflib, reactR, repurrrsive, rio, riskmetric, sharpshootR, shinydashboardPlus, shotGroups, showtext, slickR, soilDB, stars, stats19, stoRy, sunburstR, swagger, sysfonts, taxalight, thematic, tidyr, tractor.base, vcr, webfakes, wiad, winfapReader, xfun, xplorerr.

See at CRAN