File types · Explainer

The FITS file (.fits, .fit, .fts)

A FITS file is the standard data format of astronomy: images, spectra, data cubes and tables from telescopes and space missions, each with a plain-text header that describes the data. This guide explains how one is built, from its 2880-byte blocks and 80-character header cards to extensions and data types, and how to open, view and convert it.

At a glance

Full name
Flexible Image Transport System
Extensions
.fits by convention; .fit and .fts are also common; .fits.gz and .fits.fz for compressed files
MIME type
image/fits for a single image, application/fits for anything else (RFC 4047)
Kind
Binary data with ASCII headers: N-dimensional arrays (images, cubes) and tables; usually uncompressed
Standard
FITS Standard 4.0, maintained by the IAU FITS Working Group; content approved in July 2016, final edited text in August 2018
First released
1979 to 1981: first interchange in 1979, definition published in 1981, endorsed by the International Astronomical Union in 1982
Data types
Unsigned 8-bit; signed 16-, 32- and 64-bit integers; 32- and 64-bit IEEE floating point; all big-endian
Structure
One or more header and data units (HDUs), each a whole number of 2880-byte blocks
Magic number
SIMPLE = then spaces and T in column 30: 53 49 4D 50 4C 45 20 20 3D …
Opens with
SAOImage DS9, Astropy (Python), CFITSIO, ImageMagick, GIMP; not web browsers

The basics

What is a FITS file?

FITS, the Flexible Image Transport System, is how astronomers store and exchange data. It was worked out in the late 1970s by astronomers in the United States and Europe so that observatories could swap data on magnetic tape: the first FITS files were exchanged in 1979, the definition was published in 1981, and the International Astronomical Union endorsed it in 1982. The IAU's FITS Working Group has looked after it since 1988.

Despite the name, FITS isn't only for pictures. A file can hold a 1-D spectrum, a 2-D image, a 3-D data cube, catalogues and photon lists in tables, or several of these together. Data from the Hubble Space Telescope, Chandra, the Sloan Digital Sky Survey, ESO and ESA comes in FITS, and in 2010 the Vatican Library announced it would store its digitised manuscripts in FITS.

The guiding rule is "once FITS, forever FITS": a change to the standard must never make existing files invalid. Files written decades ago are still valid FITS, and current software reads them; for the same reason, files don't record which version of the standard they follow.

What a FITS file is not:

  • Not a photo format. The values are measurements, often 32-bit floats or 16-bit counts, with no fixed brightness range. A viewer has to choose how to stretch them to screen brightness, and the choice changes what you see.
  • Not compressed by default. Files are as big as their data. Compression is an add-on (see below).
  • Not shown by browsers. You need an astronomy tool, or a conversion to PNG or TIFF.

Anatomy

What's inside a FITS file

A FITS file is a series of 2880-byte blocks. The header is plain ASCII, in 80-character lines called cards; the data follows in binary. Here is a tiny FITS file made with Astropy for this page: a 4 × 3 image of 16-bit integers. Its header fits in one block, and so does its data, so the whole file is 5,760 bytes.

tiny.fits (header cards and data, 5,760 bytes)
offset 0: header, 2880 bytes (one block)
SIMPLE  =                    T / conforms to FITS standard
BITPIX  =                   16 / array data type
NAXIS   =                    2 / number of array dimensions
NAXIS1  =                    4
NAXIS2  =                    3
EXTEND  =                    T
OBJECT  = 'TEST PATTERN'       / fictional target
TELESCOP= 'NONE    '
DATE-OBS= '2026-10-27T21:00:00'
EXPTIME =                 30.0 / exposure time in seconds
END
(25 more cards of spaces fill the block: 36 × 80 = 2880)

offset 2880: data, 2880 bytes (one block)
00 00 00 64 00 C8 01 2C    0  100  200  300   first row
01 90 01 F4 02 58 02 BC  400  500  600  700
03 20 03 84 03 E8 04 4C  800  900 1000 1100
00 00 00 00 …            zeros up to 5,760 bytes
  1. 1SIMPLE = T

    The first card

    Every FITS file starts with SIMPLE, padded to 8 characters, = in columns 9 and 10, and T (true) in column 30: "this file conforms to the standard". Those 30 bytes are the format's signature, registered in RFC 4047.

  2. 2BITPIX = 16

    The data type

    Bits per value and their kind: 8 (unsigned bytes), 16, 32 or 64 (signed integers), -32 or -64 (floating point). 16 here: two bytes per pixel.

  3. 3NAXIS = 2

    The dimensions

    NAXIS is the number of axes, then NAXIS1, NAXIS2 … give their lengths. NAXIS1 is the fastest-changing axis, the width: 4 values per row, 3 rows. A spectrum has one axis, a data cube three.

  4. 4EXTEND = T

    More HDUs may follow

    Says the file may contain extensions after the primary data: more images or tables, each with its own header.

  5. 5OBJECT = 'TEST PATTERN' / fictional target

    Keywords, values, comments

    Every card is a keyword of up to 8 characters (capital letters, digits, - and _), a value and an optional comment after a /. Strings are in single quotes. Real observations carry dozens or hundreds of cards: telescope, instrument, exposure, filter, and the world coordinate system that maps pixels to positions on the sky.

  6. 6END

    The end of the header

    END has no value. The rest of the block is filled with spaces so the header is a whole number of 2880-byte blocks: 36 cards per block.

  7. 700 00 00 64 00 C8 01 2C

    The data

    The pixels, row by row, as big-endian 16-bit integers: 00 64 is 100, 00 C8 200. 12 values take 24 bytes; the rest of the 2880-byte block is zeros.

Under the hood

HDUs, extensions and data types

A FITS file is a sequence of header and data units (HDUs). The first is the primary HDU: its header starts with SIMPLE and its data, if any, is an array. Every HDU after it is an extension, whose header starts with XTENSION and names its type:

ExtensionHoldsTypical use
IMAGEAn N-dimensional array, like the primary HDUSeveral images in one file: science, error and quality maps; one per detector chip
BINTABLEA table of binary columns; a cell can hold a whole arrayCatalogues, event lists, spectra, and compressed images
TABLEA table of ASCII text columnsOlder and rarer; simple catalogues

Many files from space telescopes have an empty primary HDU (NAXIS = 0) that holds only the common header, followed by image extensions: NASA's sample files include a Hubble NICMOS observation with a null primary array and five image extensions for science, error, data quality, samples and time.

BITPIX: the data types of an image
BITPIXTypeBytes per value
8Unsigned 8-bit integer1
16Signed 16-bit integer2
32Signed 32-bit integer4
64Signed 64-bit integer8
-32IEEE 32-bit floating point4
-64IEEE 64-bit floating point8

There are no unsigned 16-bit or 32-bit types. Instead, a camera's unsigned 16-bit counts are stored as signed integers with the header keyword BZERO = 32768: a reader adds BZERO (and multiplies by BSCALE, if present) to get the real value. Astropy and CFITSIO do this automatically. All numbers are big-endian, and the 2880-byte blocks are filled out with zeros after the data, or spaces after a header.

Metadata

Reading a FITS header

The header is the part people read most. It's ASCII, so head -c 2880 image.fits | fold -w 80 in a terminal shows the first block card by card. Beyond the required keywords, observatories record everything about an observation:

  • What and when: OBJECT, DATE-OBS, EXPTIME, TELESCOP, INSTRUME, FILTER, OBSERVER.
  • Where on the sky: the World Coordinate System (WCS) keywords, such as CTYPE1, CRPIX1, CRVAL1 and CDELT1, map pixel positions to right ascension and declination, or wavelength for a spectrum.
  • Units and scaling: BUNIT, BZERO, BSCALE.
  • History: HISTORY and COMMENT cards record processing steps in free text.

Header conventions

The standard reserves some keywords; projects add their own, and conventions extend the format, such as long string values continued over several cards (CONTINUE, now part of the standard) and keywords longer than 8 characters (HIERARCH, used by ESO). Readers ignore keywords they don't know.

File size

Compressed FITS: .fits.gz and .fits.fz

Plain FITS is uncompressed, and astronomical data is large. Two approaches are common:

`.fits.gz``.fits.fz` (tile compression)
HowThe whole file gzippedThe image split into tiles, each compressed (Rice, gzip, HCOMPRESS) and stored in a binary table
Still a FITS fileNo, until it's unzippedYes: the headers stay readable
Read part of an imageNo, the whole file must be decompressedYes, tile by tile
Toolsgzip; CFITSIO and Astropy read it directlyfpack and funpack (from CFITSIO); Astropy reads it

Integer images are usually tile-compressed losslessly with Rice, which NASA's fpack documentation says typically beats gzip by about 30%. Floating-point images are usually compressed lossily: values are quantised first, which discards some of the noise. Check the settings if you need exact values.

How to

How to open, view and convert a FITS file

  • SAOImage DS9 is the standard viewer: it displays FITS images and binary tables with many scaling methods and colour maps, overlays coordinate grids and regions, and runs on Windows, macOS and Linux.
  • Astropy in Python: from astropy.io import fits, then fits.info("image.fits") lists the HDUs, fits.getheader("image.fits") returns the header and fits.getdata("image.fits") the data as a NumPy array.
  • ImageMagick reads and writes FITS: magick image.fits -auto-level image.png. It doesn't know about WCS or tables, and a high dynamic range can come out almost black or white without an explicit stretch.
  • GIMP opens FITS images for editing; Siril and other astrophotography programs stack and process them.
  • CFITSIO, NASA's C library, underlies many of these tools and comes with small utilities for listing, copying and compressing files.

Why does my FITS image look black, or upside down?

Black: the values span a range far wider than a screen can show, so most pixels map to the darkest grey. Use a logarithmic, square-root or z-scale stretch (DS9 has them all) or -auto-level in ImageMagick. Upside down: DS9 draws the first row of data at the bottom, the way astronomers plot data, and so did ImageMagick in our test; code that shows the array directly, such as Matplotlib with its default settings, puts the first row at the top. Check orientation against the coordinates, not against another program.

Comparison

FITS vs TIFF and PNG

FITSTIFFPNG
Data types8-bit unsigned, 16/32/64-bit signed, 32/64-bit floatIntegers and float, many layouts8- or 16-bit integers
DimensionsAny number of axes2-D, multiple pages2-D
TablesYesNoNo
HeaderHuman-readable ASCIIBinary tagsBinary chunks
CompressionOptional add-onMany optionsAlways (lossless)
Opens in a browserNoOnly SafariYes

Keep the FITS file as the record of a measurement; export a stretched PNG or JPG to show someone the picture. Astrophotographers often work in FITS or TIFF and publish in JPG.

Security

Is a FITS file safe to open?

A FITS file holds numbers and text and runs nothing. Some points still matter when you handle files from elsewhere:

  • Header text is input. RFC 4047 notes that local conventions where keywords refer to other files, or even control telescope hardware, need a security review. Software shouldn't act on header values it doesn't validate.
  • Size claims. NAXISn values can describe arrays far bigger than the file or than memory. Servers and pipelines should check them before allocating.
  • Headers can reveal more than intended. Observer names, site coordinates, file paths and processing history are often recorded. Read the header before publishing a file.

Sample files

There are no sample FITS files on this page yet. NASA's FITS Support Office offers sample FITS files from Hubble and other missions; to make your own, write a NumPy array with Astropy: fits.PrimaryHDU(data).writeto("test.fits").

Put it online

Have a FITS file? Give it a link.

Drop a FITS file on 99helpers and it gets its own web address. Browsers can't display FITS, so anyone who opens the link downloads it and opens it in DS9, Astropy or another astronomy tool; add a PNG preview if people should see the image in their browser.

Questions

FITS files, frequently asked

What is a FITS file?

The standard file format of astronomy: one or more images, data cubes or tables, each with a human-readable header describing the data, the observation and its sky coordinates.

How do I open a FITS file?

Use SAOImage DS9 (free, on Windows, macOS and Linux) to view it, or Astropy in Python to read it. ImageMagick and GIMP can open FITS images too, but they ignore tables and coordinates.

Are .fit, .fits and .fts the same?

Yes. All three are FITS files; .fits is the most common, and RFC 4047 says the extension is a convention rather than a rule.

How do I convert FITS to PNG or JPG?

In DS9, set a scale and colour map, then File, Save Image. On the command line: magick image.fits -auto-level image.png. The stretch you choose decides what's visible, so check the result.

Why is my FITS image black?

Its values cover a huge range and a linear display maps almost everything to black. Use a logarithmic, square-root or z-scale stretch in your viewer.

Why is every FITS file a multiple of 2880 bytes?

The standard requires headers and data to fill whole 2880-byte blocks: 36 header cards of 80 characters. The rule exists for historical reasons and has never changed, so old files stay valid.

What is the current FITS version?

Version 4.0. Its content was approved by the IAU FITS Working Group in July 2016 and the final language-edited document in August 2018.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.