

Documents: txt, tex, markdown, asciidoc, rtf, ps.Source code: c, cpp, h, cs, js, py, java, rb, pl, php, sh.Web standards: html, xml, css, svg, json.Ĭommon extensions that are text file formats: Documents: pdf, doc, xls, ppt, docx, odt.Audio: mp3, aac, wav, flac, ogg, mka, wma.Images: jpg, png, gif, bmp, tiff, psd.This is because by convention the extension reflects the file format, and it is ultimately the file format that dictates whether the file data is binary or text.Ĭommon extensions that are binary file formats: We can usually tell if a file is binary or text based on its file extension.

As a method of last resort, a hex editor can always be used to view and edit the raw bytes in any file. The reverse is not true, and treating a binary file as a text file can lead to data corruption. Every text file is indeed a binary file, but this interpretation gives us no useful operations to work with. The difference between binary and text files is in how these bytes are interpreted. Remember that all files, whether binary or text, are composed of bytes. Text files must represent reasonable text (explained later), and can be edited in any text editor program. Here is the primary difference: Binary files have no inherent constraints (can be any sequence of bytes), and must be opened in an appropriate program that knows the specific file format (such as Media Player, Photoshop, Office, etc.). Knowing the differences between binary and text files can save you time and mistakes when reading or writing data. These categories have different characteristics and need different tools to work with such files. Files can be broadly classified as either binary or text. Specifically, a file is a finite-length sequence of bytes, where each byte is an integer between 0 and 255 inclusive (represented in binary as 00000000 to 11111111). On a computer, every file is a long string of ones and zeros. What are binary and text files? Introduction
