Every header and data unit (HDU) in a FITS file starts with a header: plain ASCII
keyword records, 80 characters each, ending with an END record and padded
with spaces to a whole 2880-byte block. This page follows version 4.0 of the FITS
Standard (IAU FITS Working Group, 2016, language-edited 2018). The data that follows the
header is on the data page, the extension headers on
the extensions page and the coordinate
keywords on the world coordinates page.
Blocks and records
- A FITS block is 2880 bytes, which holds 36 keyword records of 80 bytes.
- Header records use only the ASCII characters 32 to 126 (space to tilde). There are no line ends between records.
- The header ends with the
ENDrecord. Any records left in the last block are filled with spaces (20). - The data of the HDU starts at the next 2880-byte boundary.
Keyword record
| Bytes | Size | Content |
|---|---|---|
| 1–8 | 8 | Keyword name, left-justified and padded with spaces. Only A–Z, 0–9, hyphen and underscore, no spaces inside. An index has no leading zeros (NAXIS1, never NAXIS001). |
| 9–10 | 2 | Value indicator = (equals sign, space) when the record has a value. Commentary keywords and CONTINUE do not use it. |
| 11–80 | 70 | The value, then an optional comment introduced by /. A space before the slash is strongly recommended. |
Without the value indicator, bytes 9 to 80 are free text, as in COMMENT
and HISTORY.
Value formats
Mandatory keywords must use the fixed format. Other keywords may use the free format, where the value can sit anywhere in bytes 11 to 80.
| Type | Written as | Fixed format |
|---|---|---|
| Character string | Between single quotes; a quote inside is written twice ('O''HARA'). Leading spaces count, trailing spaces do not. Up to 68 characters in one record. | Opening quote in byte 11, closing quote in or before byte 80 |
| Logical | T or F | Byte 30; in free format, the first non-space character in bytes 11 to 80 |
| Integer | Optional + or -, then decimal digits | Right-justified in bytes 11 to 30 |
| Real | Decimal number with an optional exponent, written with an upper-case E or D | Right-justified in bytes 11 to 30 |
| Complex integer | Real and imaginary parts in brackets, separated by a comma: (123, 45) | No fixed format |
| Complex real | The same, with real numbers: (123.23, -45.7) | No fixed format |
| Undefined | Nothing (only spaces) in the value field after = | – |
Long strings
A string longer than 68 characters is split with the CONTINUE
convention, part of the standard since version 4.0:
- Split the string into pieces shorter than 68 characters, never splitting a doubled quote.
- End every piece except the last with an ampersand (
&). - Write the first piece as the keyword’s value.
- Write each later piece in a
CONTINUErecord: the name in bytes 1 to 8, spaces in bytes 9 and 10, then the quoted piece.
CONTINUE must not be used with mandatory or reserved keywords unless
they are declared to take long strings.
Mandatory keywords of the primary header
| Position | Keyword | Value |
|---|---|---|
| 1 | SIMPLE | T: the file conforms to the standard. Required here, and not allowed in extensions. |
| 2 | BITPIX | Bits per data value: 8, 16, 32, 64, -32 or -64 (see data). |
| 3 | NAXIS | Number of axes, 0 to 999. Zero means no data follows. |
| 4 | NAXISn | Length of axis n, for n = 1 to NAXIS, in order. Non-negative. |
| … | Other keywords | Any order. |
| Last | END | No value; bytes 9 to 80 are spaces. |
No other keyword may come between SIMPLE and the last
NAXISn. The mandatory keywords of an extension header are on the
extensions page.
Reserved keywords for any HDU
| Keyword | Value | Meaning |
|---|---|---|
DATE | String | Date the HDU was created: YYYY-MM-DD or YYYY-MM-DDThh:mm:ss[.sss…], in UTC for data made on Earth. Files written before 2000 may use DD/MM/YY. |
DATE-OBS | String | Date of the observation, in the same format; the start of the observation unless the comment says otherwise. DATExxxx keywords follow the same rules. |
ORIGIN | String | The organisation that created the file. |
AUTHOR | String | Who compiled the data, for data taken from papers or several sources. |
REFERENC | String | Bibliographic reference, ideally an ADS bibcode or a DOI. |
TELESCOP | String | The telescope. |
INSTRUME | String | The instrument. |
OBSERVER | String | Who took the data. |
OBJECT | String | The name of the object observed. |
COMMENT | None | Commentary text in bytes 9 to 80. |
HISTORY | None | Processing history, as text in bytes 9 to 80. |
| Blank name | None | Commentary text; bytes 1 to 8 are spaces. |
CONTINUE | String | The next piece of a long string (above). |
CHECKSUM | String | 16-character checksum of the whole HDU (below). |
DATASUM | String | Checksum of the data part, as a decimal number in quotes (below). |
EXTEND | Logical | Primary header only. T says the file may contain extensions. Advisory: extensions are allowed without it. |
BLOCKED | Logical | Primary header only, deprecated. Said the tape blocking was a multiple of 2880 bytes. |
EQUINOX | Real | Equinox of the celestial coordinate system, in years (see world coordinates). |
EPOCH | Real | Deprecated older name for EQUINOX. |
Reserved keywords for arrays
These describe the values of a primary array or an IMAGE extension. How
they are applied is on the data page.
| Keyword | Value | Meaning |
|---|---|---|
BSCALE | Real | Scale factor for the stored values. Default 1.0. |
BZERO | Real | Offset added after scaling. Default 0.0. |
BUNIT | String | Physical units of the scaled values. |
BLANK | Integer | The stored value that marks an undefined pixel. Only for positive BITPIX. |
DATAMAX | Real | Largest valid physical value, ignoring IEEE special values. |
DATAMIN | Real | Smallest valid physical value, ignoring IEEE special values. |
Reserved keywords for extensions
| Keyword | Value | Meaning |
|---|---|---|
EXTNAME | String | Name that tells apart extensions of the same type. |
EXTVER | Integer | Version that tells apart extensions with the same type and name. Default 1. |
EXTLEVEL | Integer | Level in a hierarchy of extensions. Default 1. |
INHERIT | Logical | Extension headers only, directly after the mandatory keywords. T means the extension takes on the keywords of the primary header (below). |
The INHERIT convention should be used only when the primary HDU has no
data (NAXIS = 0). The mandatory primary keywords and the commentary
keywords are never inherited, nor are keywords specific to tables. When a keyword is in
both headers, the extension’s value wins. With INHERIT = F nothing is
inherited.
Checksums
Both checksums are 32-bit ones’ complement sums, taken over the bytes as big-endian 32-bit integers (with the carry out of bit 31 added back into bit 0).
DATASUMis the sum over the data blocks of the HDU, written as an unsigned decimal number in quotes, such as'2503531142'. It must be updated beforeCHECKSUM.CHECKSUMmakes the sum over the whole HDU, header and data, come out as negative zero (all ones). To write it, set the value to sixteen0characters, sum the HDU, and take the complement of the sum.- The complement is encoded as 16 characters. Each of its four bytes is split into
four parts that add up to the byte,
0x30(ASCII0) is added to each part, and the 16 values are interleaved as A1 B1 C1 D1 A2 B2 C2 D2 … Pairs are then adjusted so that every character is a letter or digit, never:to@(3A–40) or[to`(5B–60). - Finally the 16 characters are rotated one place to the right (the last moves to the front), because the string starts in byte 12 of its record, one byte before a 4-byte boundary.
A complete primary header
This header describes a 100 by 100 image of 16-bit integers. Each line here is one
80-byte record; in the file the records follow each other with no line ends, and the
block is padded to 2880 bytes with spaces. The T of SIMPLE
is in byte 30, and the integers end in byte 30.
SIMPLE = T / file conforms to the FITS standard
BITPIX = 16 / 16-bit two's complement integers
NAXIS = 2 / number of axes
NAXIS1 = 100 / width in pixels
NAXIS2 = 100 / height in pixels
EXTEND = T / extensions may follow
OBJECT = 'M31' / name of the object
DATE = '2016-07-22' / date the file was written
END
The same first record as bytes: 53 49 4D 50 4C 45 20 20 is
SIMPLE with two spaces, 3D 20 is the value indicator, then
19 spaces and 54 (T).
Conventions outside the standard
Some widely used conventions are registered with the FITS Support Office but are not
part of the standard, for example ESO’s HIERARCH convention for keyword
names longer than eight characters. A reader that does not know a convention sees
ordinary records and can skip them.