Showing posts with label File Formats. Show all posts
Showing posts with label File Formats. Show all posts

Monday, September 21, 2026

What Is a ZIP File?

// file formats

What Is a ZIP File?

A ZIP file is an archive file that can combine multiple files and folders into a single package. It can also compress the data inside, reducing the amount of storage space required and making collections of files easier to transfer.

// definition

ZIP is an archive format

A ZIP file is an archive that can contain one or more files and directories.

The contents can be stored together inside a single file ending in the .zip extension.

ZIP also supports lossless compression, allowing many types of data to be stored using fewer bytes.

// example

Several files can become one archive

Suppose a folder contains:

project/ │ ├── index.html ├── styles.css ├── script.js └── logo.png

The entire folder could be packaged as:

project.zip

Instead of sending four separate files and their folder structure, you can send a single archive.

// archive

ZIP preserves files and folders together

A ZIP archive can preserve directory structure.

website.zip │ ├── index.html │ ├── css/ │ └── styles.css │ ├── js/ │ └── app.js │ └── images/ └── logo.png

When the archive is extracted, the original folder structure can be recreated.

// compression

ZIP files can compress data

Compression attempts to represent the same information using fewer bytes.

Original files ↓ Compression ↓ Smaller ZIP archive

The amount saved depends heavily on the type of data being compressed.

// lossless

ZIP compression is lossless

Lossless compression means the original information can be reconstructed exactly when the archive is decompressed.

Original file ↓ Compress ↓ ZIP data ↓ Extract ↓ Original file restored

No content needs to be deliberately discarded. This is different from lossy formats that may remove information to achieve smaller file sizes.

// file size

Not every file becomes much smaller

Text-based files often compress very effectively because they can contain repeated patterns.

TXT CSV XML HTML JSON

Files that are already compressed may shrink very little.

JPEG MP3 MP4 PNG

In some cases, placing already compressed data inside a ZIP archive may produce almost no size reduction.

// storage

ZIP can also store files without compression

A ZIP archive does not require every file inside it to be compressed.

Entries can also be stored directly while still benefiting from the archive structure.

ZIP archive │ ├── file1.txt → compressed ├── photo.jpg → stored └── video.mp4 → stored
// extraction

What does "extract" mean?

Extracting a ZIP file means taking files out of the archive and restoring them as ordinary files and folders.

project.zip ↓ Extract ↓ project/ ├── index.html ├── styles.css └── script.js

The ZIP archive itself can remain unchanged after extraction.

// creating

What does "zip" a folder mean?

To zip files means to package them inside a ZIP archive.

Folder ↓ Create ZIP archive ↓ folder.zip

Operating systems such as Windows and macOS include built-in tools for creating and extracting ZIP archives.

// internal structure

A ZIP file contains multiple file records

Internally, ZIP stores information about the files inside the archive.

This can include:

File Names Folder Paths Compressed Data File Sizes Checksums Timestamps
// directory

ZIP files contain a central directory

A ZIP archive normally contains a central directory describing the entries stored inside it.

ZIP archive │ ├── File data ├── File data ├── File data │ └── Central directory ├── file names ├── locations ├── sizes └── metadata

Software can use this information to find and list the archive's contents.

// integrity

ZIP files can detect some forms of corruption

ZIP entries commonly include a CRC-32 checksum.

The checksum can be used to check whether extracted data matches the data expected by the archive.

Stored checksum ↓ Extracted file ↓ Calculate checksum ↓ Compare values
// encryption

ZIP archives can be password-protected

Some ZIP tools support encryption so that the archive contents cannot be read without the required password.

Password protection and compression are different things. Compression reduces or packages data. Encryption is intended to protect data from unauthorised access.

// container format

ZIP is also used as a container for other file formats

Some file formats are actually specialised ZIP packages.

Format What it contains
.xlsx Excel workbook XML and supporting files
.docx Word document XML and supporting files
.pptx PowerPoint XML and supporting files

These formats use ZIP as the underlying package containing multiple structured files.

// xlsx example

An .xlsx file is a specialised ZIP package

workbook.xlsx ↓ ZIP package ↓ xl/ ├── workbook.xml ├── styles.xml └── worksheets/ └── sheet1.xml

This is why renaming a copy of an .xlsx file to .zip can allow ZIP software to inspect its internal structure.

// zip vs folder

A ZIP archive is not the same as a normal folder

Folder ZIP archive
Directory on a file system Single archive file
Contains files directly Packages entries inside the archive
No compression by itself Can compress contained files
Easy to edit directly Usually extracted or modified with archive software
// archive formats

ZIP is one of several archive formats

ZIP RAR 7Z TAR GZIP

These formats have different features, compression methods and levels of software support.

ZIP is particularly widespread because support is built into many operating systems and applications.

// programming

Software can create ZIP files automatically

Programming languages can create, inspect and extract ZIP archives.

Python PHP JavaScript Java C#
// python example

Python can create ZIP archives

import zipfile with zipfile.ZipFile( "project.zip", "w", zipfile.ZIP_DEFLATED ) as archive: archive.write("index.html") archive.write("styles.css")

The program creates an archive and adds files to it.

// automation

ZIP files are useful in automated workflows

Generate files ↓ Create ZIP ↓ Upload archive ↓ Send to customer ↓ Customer extracts files

This makes ZIP useful for exports, backups, downloadable packages and batch processing.

// backups

ZIP files are commonly used for backups

A group of related files can be bundled into one archive:

website-backup.zip │ ├── html/ ├── css/ ├── images/ ├── scripts/ └── data/

This makes the collection easier to copy, store and transfer.

// transfer

ZIP files make collections easier to send

Instead of attaching twenty separate files to a message, they can be placed inside one archive.

20 files ↓ project.zip ↓ 1 attachment
// security

ZIP files should still be treated carefully

A ZIP archive can contain almost any type of file, including executable programs and scripts.

Receiving a file inside a ZIP archive does not make that file automatically safe.

Only extract and run files from sources you trust. An archive is simply a container and does not guarantee that its contents are harmless.

// uses

What are ZIP files used for?

File Transfer Compression Backups Software Downloads Website Files Data Exports Document Packages Automation Archiving
// mental model

The simplest way to think about a ZIP file

Files + folders ↓ Package together ↓ Optional compression ↓ archive.zip ↓ Transfer or store ↓ Extract ↓ Original files + folders
// summary

Many files. One package.

A ZIP file is an archive format that can package multiple files and folders into a single file. ZIP supports lossless compression, preserves directory structures and is widely used for transfers, backups, downloads and software packaging. Some formats such as XLSX, DOCX and PPTX also use ZIP internally as their container format.

What Is an .xlsx File?

// spreadsheets

What Is an .xlsx File?

An .xlsx file is a modern spreadsheet file format used by Microsoft Excel and many other spreadsheet programs. It can store worksheets, numbers, text, formulas, tables, charts, formatting and other structured spreadsheet data.

// definition

.xlsx is a spreadsheet file format

An .xlsx file is a spreadsheet workbook stored using Microsoft's Office Open XML spreadsheet format.

It is commonly associated with Microsoft Excel, although other spreadsheet applications can also read and write .xlsx files.

A single workbook can contain multiple worksheets along with formulas, formatting, charts and other spreadsheet information.

// file extension

What does .xlsx mean?

The .xlsx extension identifies an Excel workbook stored using the Office Open XML format.

budget.xlsx customers.xlsx sales-data.xlsx project-tracker.xlsx

The extension tells software what kind of file it is dealing with and which format should be used to interpret the contents.

// workbook

An .xlsx file is a workbook

A workbook can contain one or more worksheets.

sales.xlsx │ ├── January ├── February ├── March └── Summary

Each worksheet contains a grid of rows and columns.

// cells

Spreadsheet data is stored in cells

Each cell is identified by a column and row.

A1 B1 C1 A2 B2 C2

For example:

A B C
Product Quantity Price
Keyboard 2 39.99
Mouse 4 19.50
// cell values

Cells can contain different kinds of information

Text Numbers Dates Times Formulas Booleans Errors
// formulas

.xlsx files can store formulas

A spreadsheet cell does not have to contain only a fixed value.

It can contain a formula:

=A1+B1

or:

=SUM(B2:B20)

The spreadsheet application evaluates the formula and displays the calculated result.

// formula + value

A formula and its displayed result are different things

Suppose a cell contains:

=10+20

The displayed result may be:

30

The workbook can retain the formula rather than simply replacing it with the number 30.

// formatting

.xlsx files can store presentation information

Unlike a simple CSV file, an .xlsx workbook can retain substantial visual formatting.

Fonts Colours Borders Alignment Number Formats Column Widths Row Heights Conditional Formatting
// workbook features

A workbook can contain much more than cells

Worksheets

Multiple spreadsheet pages can exist inside one file.

Charts

Data can be visualised using charts and graphs.

Tables

Structured Excel tables can organise related records.

Formulas

Calculations can reference other cells and sheets.

Validation

Rules can restrict what users are allowed to enter.

Hyperlinks

Cells can contain links to websites and other resources.

// office open xml

An .xlsx file is based on XML

The modern Excel workbook format belongs to the Office Open XML family of file formats.

Internally, workbook information is divided across a collection of structured XML files and related resources.

Workbook ↓ XML documents + relationships + styles + other resources
// zip container

An .xlsx file is also a ZIP package

One of the most interesting facts about .xlsx files is that they are packaged using ZIP compression.

If a copy of an .xlsx file is renamed from:

workbook.xlsx

to:

workbook.zip

ZIP-compatible software can usually open the package and reveal the internal files.

An .xlsx file is not one giant XML document. It is a ZIP package containing multiple XML documents and supporting files organised according to the Office Open XML format.

// internal structure

What is inside an .xlsx file?

A simplified workbook package might contain:

workbook.xlsx │ ├── [Content_Types].xml ├── _rels/ │ ├── docProps/ │ └── xl/ │ ├── workbook.xml ├── styles.xml ├── sharedStrings.xml ├── worksheets/ │ ├── sheet1.xml │ └── sheet2.xml │ └── _rels/

The exact contents depend on which features are used in the workbook.

// worksheet xml

Worksheets are represented using XML

Internally, a worksheet may contain XML structures representing rows and cells.

<row r="1"> <c r="A1"> ... </c> </row>

Spreadsheet software interprets these structures and presents them as the familiar grid seen in Excel.

// shared strings

Text may be stored separately from worksheet cells

Some .xlsx workbooks use a shared strings table.

Instead of repeating the same text many times inside worksheets, cells can reference entries stored in a shared XML structure.

Cell ↓ String reference ↓ sharedStrings.xml ↓ "Freelance Coder"
// styles

Formatting can be stored separately

Workbook styles can be defined in internal style information and referenced by cells.

This avoids having to repeat complete formatting instructions for every individual cell.

// xlsx vs xls

.xlsx replaced the older .xls format

.xls .xlsx
Older Excel format Modern Excel workbook format
Binary file format Office Open XML package
Associated with older Excel versions Introduced with Excel 2007
Legacy format Common modern format
// xlsx vs csv

.xlsx and .csv are very different

CSV XLSX
Plain-text format ZIP-based spreadsheet package
Usually represents one table Can contain multiple worksheets
No native cell formatting Supports extensive formatting
No native charts Can contain charts
Simple data exchange Complete spreadsheet workbook
// important distinction

Saving Excel data as CSV can remove workbook features

Suppose an .xlsx workbook contains:

3 worksheets formulas colours charts cell formatting

Exporting one sheet to CSV normally preserves the tabular values but not the complete workbook structure.

XLSX → full spreadsheet workbook CSV → plain tabular data
// macros

.xlsx files do not normally contain VBA macros

Excel uses a different extension for macro-enabled workbooks:

.xlsm
Extension Workbook type
.xlsx Standard Excel workbook
.xlsm Macro-enabled Excel workbook

This distinction matters. If a workbook depends on VBA macros, saving it as an ordinary .xlsx file is not the appropriate format for retaining those macros.

// programming

.xlsx files can be created by software

Excel itself is not required to generate every .xlsx workbook.

Programming libraries can create, read and modify spreadsheet files automatically.

Python JavaScript PHP Java C# Automation
// python example

Python can create .xlsx files

For example, libraries such as openpyxl can work with Excel workbooks.

from openpyxl import Workbook workbook = Workbook() sheet = workbook.active sheet["A1"] = "Product" sheet["B1"] = "Price" sheet["A2"] = "Keyboard" sheet["B2"] = 39.99 workbook.save("products.xlsx")

Software can therefore generate spreadsheets from databases, APIs and other data sources.

// automation

Spreadsheet generation can be automated

API ↓ Application ↓ Process data ↓ Generate .xlsx ↓ Spreadsheet report

This is useful for reporting, financial data, exports, project tracking and business workflows.

// compatibility

.xlsx files are supported by many applications

Microsoft Excel is the application most strongly associated with .xlsx, but other spreadsheet software can also work with the format.

Microsoft Excel Google Sheets LibreOffice Calc Spreadsheet Libraries

Complex workbook features may not always behave identically when the same file is opened in different spreadsheet applications.

// not plain text

An .xlsx file is not a plain-text file

Although its internal structure contains XML documents, the .xlsx file itself is a compressed package.

Opening it directly in a basic text editor will therefore not display the workbook in the same clean way as opening a CSV, TXT or XML file.

TXT → plain text CSV → plain text XML → plain text XLSX → compressed package containing XML and other resources
// uses

What are .xlsx files used for?

Budgets Accounts Data Analysis Reports Project Tracking Invoices Customer Lists Dashboards Financial Models Data Exports
// mental model

The simplest way to think about .xlsx

.xlsx file ↓ ZIP package ↓ XML + relationships + resources ↓ Workbook ↓ Worksheets ↓ Rows + columns + cells ↓ Values + formulas + formatting
// summary

More than just a table.

An .xlsx file is a modern spreadsheet workbook format based on Office Open XML. It can contain multiple worksheets, values, formulas, formatting, charts and other spreadsheet features. Internally, the workbook is stored as a ZIP package containing XML documents and related resources.

Friday, September 18, 2026

What Is JSON?

// data formats

What Is JSON?

JSON is a lightweight text-based format for representing structured data. It is widely used by websites, APIs, applications and programming languages to exchange information in a form that is relatively easy for both humans and computers to understand.

// definition

JSON means JavaScript Object Notation

JSON stands for JavaScript Object Notation.

It is a text-based format used to represent structured information using objects, arrays, names and values.

Although JSON originated from JavaScript syntax, it is now used independently by many programming languages and software systems.

// example

What does JSON look like?

Suppose we want to store information about a customer.

{ "name": "Alice Smith", "email": "alice@example.com", "orders": 4, "active": true }

This is a JSON object.

Each piece of information consists of a name and a value.

// name-value pairs

JSON uses name-value pairs

Consider this line:

"name": "Alice Smith"

The name of the property is:

"name"

and its value is:

"Alice Smith"

A colon separates the property name from its value. Commas separate different properties.

// objects

JSON objects use curly braces

An object begins with { and ends with }.

{ "product": "Keyboard", "price": 49.99, "stock": 12 }

Objects are useful when several named properties belong to the same thing.

// arrays

JSON arrays use square brackets

An array represents an ordered collection of values.

[ "HTML", "CSS", "JavaScript", "PHP" ]

Arrays begin with [ and end with ].

// collections

Arrays can contain objects

This is extremely common when working with APIs and databases.

[ { "name": "Alice", "orders": 4 }, { "name": "Ben", "orders": 7 }, { "name": "Carla", "orders": 2 } ]

Here, the array contains three separate customer objects.

// data types

JSON supports several kinds of values

Type Example
String "Freelance Coder"
Number 42
Boolean true
Null null
Object { "name": "Alice" }
Array [1, 2, 3]
// strings

JSON strings use double quotation marks

{ "city": "London" }

JSON requires strings and property names to use double quotation marks.

Important: JSON does not allow property names or strings to be written using single quotation marks in standard JSON syntax.

// boolean values

JSON can represent true and false

{ "active": true, "verified": false }

Boolean values are written without quotation marks.

// null

JSON can represent no value

{ "middleName": null }

The value null represents the intentional absence of a value.

// nesting

JSON can represent complex structures

Objects can contain other objects and arrays.

{ "customer": { "name": "Alice", "location": { "city": "Birmingham", "country": "United Kingdom" }, "orders": [ { "id": 1001, "total": 49.99 }, { "id": 1002, "total": 25.50 } ] } }

This creates a hierarchical structure in which related information can be grouped together.

// APIs

JSON is widely used by APIs

One of JSON's most important uses is transferring data between software systems.

For example, an application might request information about a product from an API and receive:

{ "id": 1042, "name": "Wireless Keyboard", "price": 39.99, "available": true }

The application can then read the JSON and use the values in its own interface or processing.

// data exchange

JSON helps systems communicate

Website ↓ API request ↓ Server ↓ JSON response ↓ Website

JSON provides a common structure that both sides can understand.

// json vs csv

JSON and CSV solve different problems

CSV works particularly well for simple tabular data.

Name,Orders Alice,4 Ben,7

JSON can represent more complex nested structures.

{ "customers": [ { "name": "Alice", "orders": [ 1001, 1002 ] } ] }
CSV JSON
Rows and columns Objects and arrays
Excellent for tables Excellent for structured data
Flat structure Can be nested
// json vs xml

JSON and XML can represent similar data

This XML:

<customer> <name>Alice</name> <orders>4</orders> </customer>

could be represented in JSON as:

{ "customer": { "name": "Alice", "orders": 4 } }

JSON is often more compact for application data, while XML provides additional features that can be useful for document-oriented and specialised systems.

// plain text

JSON is a text format

JSON may represent complex information, but the underlying document is still text.

This means JSON can be opened in a text editor, transmitted over a network and processed by many different programming languages.

Text-Based Structured Portable Machine-Readable Human-Readable
// utf-8

JSON and UTF-8

JSON exchanged between systems is commonly encoded using UTF-8.

{ "name": "João", "currency": "£", "symbol": "π", "message": "Olá" }

UTF-8 allows JSON to represent a very wide range of Unicode characters reliably.

// .json files

JSON can be stored in .json files

JSON data saved as a standalone file normally uses the .json file extension.

customers.json products.json settings.json data.json

JSON does not have to exist as a separate file, however. It can also be sent directly between applications and APIs.

// advantages

Why is JSON so widely used?

Readable

Its structure is relatively easy for people to inspect and understand.

Lightweight

JSON can represent structured information without large amounts of additional markup.

Structured

Objects, arrays and nested values can represent sophisticated data structures.

Widely supported

Most modern programming languages and web technologies can read and generate JSON.

// uses

Where is JSON used?

APIs Web Applications Databases Configuration Automation AI Systems Data Exchange JavaScript Mobile Apps Cloud Services
// syntax

JSON syntax is strict

Valid JSON must follow specific rules.

Property names use double quotes.

Strings use double quotes.

Properties are separated by commas.

Trailing commas are not permitted in standard JSON.

For example, this is valid:

{ "name": "Alice", "age": 30 }

But this is not valid standard JSON:

{ 'name': 'Alice', 'age': 30, }
// summary

Simple text. Structured information.

JSON is a text-based format for representing structured data using objects, arrays and name-value pairs. Its simplicity, flexibility and widespread software support make it one of the most important formats for APIs, websites, applications, automation and modern data exchange.

What Is UTF-8?

// character encoding

What Is UTF-8?

UTF-8 is a character encoding used to represent text inside computers. It provides a way of turning Unicode characters such as letters, numbers, mathematical symbols and characters from many languages into bytes that a computer can store and process.

// definition

UTF-8 turns characters into bytes

UTF-8 stands for Unicode Transformation Format - 8-bit.

It is an encoding system that converts Unicode characters into sequences of bytes.

This allows text to be stored in files, transmitted across networks and interpreted consistently by different computer systems.

// why encoding?

Computers do not store letters directly

When we look at a computer screen, we see characters:

A £ π é 日 😀

But computer storage ultimately consists of binary data. The computer therefore needs a defined system for representing each character using numbers and bytes.

Character → Unicode code point → UTF-8 encoding → Bytes
// unicode

First, understand Unicode

Unicode is a standard that assigns characters unique numerical identifiers called code points.

A Unicode code point is normally written using U+ followed by hexadecimal digits.

Character Unicode code point
A U+0041
£ U+00A3
é U+00E9
π U+03C0
€ U+20AC
😀 U+1F600
// unicode vs utf-8

Unicode and UTF-8 are not the same thing

This distinction is important.

Unicode

Defines characters and assigns them code points.

UTF-8

Defines how those Unicode code points are encoded into bytes.

Unicode tells us that the pound sign is U+00A3. UTF-8 tells the computer which bytes should be used to represent that character.

// bytes

UTF-8 uses between one and four bytes

UTF-8 is a variable-length encoding.

Different characters require different numbers of bytes.

Character UTF-8 bytes Bytes used
A 41 1
£ C2 A3 2
π CF 80 2
€ E2 82 AC 3
😀 F0 9F 98 80 4

Important: the hexadecimal byte values shown above are the UTF-8 encoding of each character, not the Unicode code point itself.

// ascii compatibility

UTF-8 is compatible with ASCII

One of the reasons UTF-8 became so successful is its compatibility with ASCII.

The first 128 Unicode characters use exactly the same single-byte values as ASCII.

A = U+0041 = UTF-8 byte 41 B = U+0042 = UTF-8 byte 42 1 = U+0031 = UTF-8 byte 31

This means ordinary English text using basic letters, digits and punctuation is very compact in UTF-8.

// multilingual text

UTF-8 can represent text from many languages

UTF-8 is not limited to English.

English: Hello Português: Olá Español: Información Français: Éducation Greek: π Japanese: 日本 Currency: £ € ¥ Mathematics: ≤ ≥ ± √ ∞ Emoji: 😀

All of these characters can exist within the same UTF-8 encoded document.

// encoding errors

What happens when the wrong encoding is used?

Text can become corrupted-looking when software interprets bytes using the wrong character encoding.

For example, a pound sign encoded as UTF-8 may sometimes incorrectly appear as:

Expected: £50 Incorrect interpretation: £50

This type of garbled text is often called mojibake.

The data may not actually be damaged. The same bytes may simply have been interpreted using the wrong encoding.

// txt files

UTF-8 and .txt files

A .txt file tells us that a file contains plain text, but it does not automatically tell us which character encoding was used.

.txt ≠ automatically UTF-8

A text file might use UTF-8, ASCII, Windows-1252 or another encoding.

For modern text files, UTF-8 is generally the most useful and interoperable choice.

// csv files

UTF-8 and CSV

CSV is also a text-based format, so character encoding matters.

Name,City,Amount João,Lisboa,£50 Élodie,Paris,€75 Sofia,Athens,€40

Saving this file using UTF-8 helps preserve accented characters and currency symbols when the file moves between compatible systems.

// xml

UTF-8 and XML

XML documents can explicitly declare their character encoding.

<?xml version="1.0" encoding="UTF-8"?>

This tells the software reading the document that its characters are encoded using UTF-8.

// html

UTF-8 on websites

Websites also need to specify how text should be interpreted.

Modern HTML pages commonly include:

<meta charset="UTF-8">

This tells the browser to interpret the document using UTF-8.

Correct encoding is important for displaying names, symbols, mathematical notation, international text and other characters reliably.

// advantages

Why is UTF-8 so widely used?

Unicode support

It can represent the full range of Unicode code points.

ASCII compatible

Basic ASCII characters retain their original one-byte representation.

Efficient

Common English characters require only one byte, while additional bytes are used when necessary.

Portable

UTF-8 is supported across operating systems, programming languages, databases and web technology.

// where it appears

UTF-8 appears throughout modern computing

UTF-8 can be used with many text-based technologies and file formats.

TXT CSV XML JSON HTML CSS JavaScript APIs Databases Web Pages
// key idea

The file format and the encoding are different things

This is one of the most useful concepts to understand.

File format: describes how information is organised.

Character encoding: describes how the characters themselves are represented as bytes.

CSV = structure of the data UTF-8 = encoding of the characters

A CSV file can therefore be encoded using UTF-8. An XML document can be encoded using UTF-8. A plain .txt file can also be encoded using UTF-8.

// summary

Characters become bytes.

UTF-8 is a character encoding that converts Unicode characters into sequences of one to four bytes. It allows computers to store and exchange text from many languages, symbols and writing systems while remaining compatible with ASCII.

What Is XML?

// file formats

What Is XML?

XML is a text-based format for storing and exchanging structured information. It uses descriptive tags to show what each piece of data means and how different pieces of information relate to one another.

// definition

XML means Extensible Markup Language

XML stands for Extensible Markup Language.

It is a plain-text format designed to describe, organise, store and exchange structured information.

XML does this using tags that identify the meaning and structure of the data.

// example

What does XML look like?

Imagine that we want to store information about a customer.

<customer> <name>Alice Smith</name> <email>alice@example.com</email> <orders>4</orders> </customer>

The information is surrounded by tags such as <name>, <email> and <orders>.

These tags give meaning to the values rather than simply storing them in a fixed position.

// tags

Opening and closing tags

Most XML elements have an opening tag and a closing tag.

<name>Alice Smith</name>

Here:

<name>

This is the opening tag. It marks the beginning of the element.

</name>

This is the closing tag. The forward slash indicates the end of the element.

// structure

XML is hierarchical

One of XML's most important features is that elements can contain other elements.

This creates a tree-like hierarchy.

<shop> <customer> <name>Alice</name> <orders> <order> <id>1001</id> <total>49.99</total> </order> <order> <id>1002</id> <total>25.50</total> </order> </orders> </customer> </shop>

In this example, the shop contains a customer, the customer contains orders, and each order contains its own information.

// root element

An XML document needs a root element

A well-formed XML document has one outermost element that contains the rest of the document.

<customers> <customer> <name>Alice</name> </customer> <customer> <name>Ben</name> </customer> </customers>

Here, <customers> is the root element.

// attributes

XML elements can also have attributes

Attributes provide additional information about an element.

<customer id="1042" status="active"> <name>Alice Smith</name> </customer>

In this example:

id="1042" status="active"

These are attributes attached to the customer element.

// extensible

Why is XML called "extensible"?

XML does not give you a fixed set of tags.

Instead, you can create tags appropriate to the information you are describing.

<book> <title>Introduction to Data</title> <author>Jane Smith</author> </book>

A different system might use:

<product> <sku>ABC-100</sku> <price>29.99</price> </product>

The tags can therefore be designed around the type of information being stored.

// declaration

The XML declaration

XML documents may begin with a declaration such as:

<?xml version="1.0" encoding="UTF-8"?>

This tells software that the document uses XML version 1.0 and that the text is encoded using UTF-8.

Important: XML is a text format, so character encoding matters. UTF-8 is extremely common because it can represent characters from many languages and writing systems.

// escaping

Some characters need special handling

Because characters such as angle brackets are used as part of XML syntax, certain characters must be represented using special entity references when they are intended as data.

Character XML representation
< &lt;
> &gt;
& &amp;
" &quot;
' &apos;
// rules

XML has strict structural rules

XML must be well formed for an XML parser to process it correctly.

Tags must close

Elements normally need corresponding opening and closing tags.

Tags must nest correctly

Elements cannot overlap one another incorrectly.

One root element

The document must have one outermost root element.

XML is case-sensitive

<Name> and <name> are treated as different tags.

// nesting

Correct nesting matters

This is valid:

<customer> <name>Alice</name> </customer>

But this structure is invalid:

<customer> <name>Alice </customer> </name>

The elements have been closed in the wrong order.

// xml vs html

XML and HTML look similar, but they have different purposes

Both use angle-bracket tags, but they are designed for different jobs.

XML HTML
Describes and structures data Structures content for web pages
Custom tags can be created Uses predefined HTML elements
Focused on information Focused on webpage structure and presentation
Strict syntax Browsers are often more forgiving
<!-- XML --> <product> <name>Keyboard</name> <price>49.99</price> </product> <!-- HTML --> <h1>Keyboard</h1> <p>Price: £49.99</p>
// xml vs json

XML and JSON can represent similar information

XML and JSON are both commonly used to represent structured data.

For example, this XML:

<customer> <name>Alice</name> <orders>4</orders> </customer>

could be represented in JSON as:

{ "customer": { "name": "Alice", "orders": 4 } }

JSON is often more compact, while XML offers features such as attributes, namespaces and document-oriented structures that can be useful in more complex systems.

// uses

What is XML used for?

XML has been used extensively for exchanging and storing structured information across many kinds of software.

Configuration Files Data Exchange Web Services Document Formats Product Feeds Sitemaps RSS Feeds APIs Data Imports Data Exports
// real-world example

Website sitemaps commonly use XML

A website can provide an XML sitemap containing information about its pages.

<urlset> <url> <loc>https://example.com/</loc> </url> <url> <loc>https://example.com/about</loc> </url> </urlset>

Search engines and other software can process this structured information automatically.

// data management

Why XML matters in data management

XML allows information to describe its own structure.

Instead of relying purely on column positions or an external explanation, tags can identify what individual pieces of information represent.

<employee> <name>Tiago</name> <department>Technology</department> <active>true</active> </employee>

This makes XML useful when information needs to move between systems while retaining a clear hierarchical structure.

// plain text

XML is still plain text

Although XML can represent complex structures, the file itself is text.

This means an XML file can be opened in a text editor, inspected by a person and processed by software.

Readable Portable Structured Machine-Readable Text-Based
// summary

Text with structure and meaning.

XML is a text-based language for representing structured information. It uses tags, elements, attributes and hierarchical relationships to describe what data means and how different pieces of information fit together.

What Is an IP Address?

// networking What Is an IP Address? An IP address is a numerical address used t...