.rds

What is a .rds file?

R Serialized Data File · Data · R Core Team · 2000 (R 1.0)

An .rds file stores a single R object, saved with saveRDS() in the R statistics language. Its siblings .RData and .rda hold whole collections of objects saved with save(). All are R's native serialization.

Category
Data
Type
Binary
Also seen as
.rdata, .rda
Is a .rds file safe to open? Mostly safe: it is serialized data. Loading an .RData file can however replace objects in your R session, and maliciously crafted serialized objects are a known risk in any language, so load files only from sources you trust.

What is a .rds file used for?

R analysts save models, data frames and results this way because everything survives exactly: types, factors, attributes. An .rds file holds one object you assign on load; .RData restores objects under their original names into your session.

The files are normally gzip-compressed R serialization, so there is no single fixed signature to look for. Only R (or rpy2/pyreadr bridges) reads them, which is why sharing data outside R usually means exporting CSV or parquet instead.

How to open a .rds file

The .rds format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .rds file.

Windows

  • R / RStudio
  • Python (pyreadr)

macOS

  • R / RStudio
  • Python (pyreadr)

Linux

  • R / RStudio
  • Python (pyreadr)

How to convert a .rds file

You can convert a .rds file to csv, parquet, xlsx using a conversion tool or the export menu of an app that opens it.

.rds file signature (magic bytes)

Programs recognise a .rds file by the bytes at the start of the file, not by its name. These are the signatures for RDS.

Hex signatureOffsetNote
(no fixed signature)0no fixed magic; structure defined by a schema or header

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .rds file?

An .rds file stores a single R object, saved with saveRDS() in the R statistics language. Its siblings .RData and .rda hold whole collections of objects saved with save(). All are R's native serialization.

How do I open an .rds file?

In R: x <- readRDS("file.rds"). In Python, the pyreadr package reads both .rds and .RData without an R installation.

What is the difference between .rds and .RData?

.rds (saveRDS) stores one object without its name, so you assign it on load. .RData/.rda (save) stores several named objects that load straight into your environment.

How do I convert .rds to CSV?

Load it in R with readRDS() and write it out with write.csv() or readr::write_csv(). For big tables, arrow::write_parquet() keeps types better.

Related formats

Sources

Details on this page were checked against authoritative references: