A file format is a specification of the structure of data recorded in a computer file. The file format identifier is usually indicated at the end of the file name in the form of an "extension". The file name extension helps identify the format of the data contained in the file to programs that can work with it. Sometimes the data format is additionally specified at the beginning of the file content.
The operating system uses file-to-program mapping (association) to determine which program can open a file.
For example, the name extension ".txt" is usually used to refer to files that contain only textual information, and ".doc" is used to refer to textual information structured according to Microsoft Word standards. Files whose contents correspond to the same format (less commonly, to the same format family) are sometimes referred to as files of the same type.
Since the common concept of a file in computing is an unstructured sequence of bytes, computer programs that store structured data in files must somehow convert it into a sequence of bytes and vice versa (in OOP, these operations are called "serialization" and "deserialization," respectively; for textual information, the latter is also called "parsing" or "parsing"). The algorithm for these transformations, as well as the conventions on how the various pieces of structured data are arranged within the file and make up its "format."
Different file formats may differ in the level of detail, one format may be an "add-on" to another, or use elements of other formats. For example, the text format imposes only the most general constraints on the data structure. The HTML format sets additional rules on the internal structure of the file, but any HTML file is also a text file.
Another example is the structure of computer programs, i.e. executable files: it must strictly conform to certain expectations (specifications) of the operating system that runs it.