MySQL
Text Data Types
Storage Sizes
Database Management
SQL Limits

MySQL TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT maximum sizes

Codemia Knowledge Hub ·

MySQL's four TEXT types store variable-length text up to these maximums: TINYTEXT 255 bytes, TEXT 65,535 bytes (64 KB), MEDIUMTEXT 16,777,215 bytes (16 MB) and LONGTEXT 4,294,967,295 bytes (4 GB). The limits are in bytes, so with a multi-byte character set such as utf8mb4 the number of characters you can store is lower.

Text TypeMaximum Characters (single-byte charset)Maximum BytesStorage Notes
TINYTEXT2552551 byte for prefix.
TEXT65,53565,5352 bytes for prefix.
MEDIUMTEXT16,777,21516,777,2153 bytes for prefix.
LONGTEXT4,294,967,2954,294,967,2954 bytes for prefix.

Each type in detail

TINYTEXT

  • Maximum size: 255 bytes, the smallest of the four. That is 255 characters only when every character is one byte.
  • Overhead: One extra byte stores the length prefix.
  • Use case: Short descriptions or notes.

TEXT

  • Maximum size: 65,535 bytes (64 KB).
  • Overhead: Two bytes for the length prefix.
  • Use case: Medium-length text such as blog post excerpts, user comments or short articles.

MEDIUMTEXT

  • Maximum size: 16,777,215 bytes (16 MB).
  • Overhead: Three bytes for the length prefix.
  • Use case: Larger text such as long blog articles, document content or large JSON strings.

LONGTEXT

  • Maximum size: 4,294,967,295 bytes (4 GB), the largest of the four.
  • Overhead: Four bytes for the length prefix.
  • Use case: Very large data such as long user-submitted text, entire books or massive logs.

How character encoding reduces the character limit

The default character set is often utf8 or utf8mb4, where one character can take more than one byte:

  • utf8: Each character can use up to 3 bytes.
  • utf8mb4: Each character can use up to 4 bytes.

If your data includes multi-byte characters, you can store fewer characters than the byte maximum.

Performance and indexing

  • Resource use: Larger types such as LONGTEXT offer plenty of space but can use more memory and processing power, which affects database performance.
  • Indexing: MySQL cannot index the full length of large text columns. You have to specify a prefix length for the index.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design