VARCHAR vs TEXT in MySQL — Which Should You Use?
VARCHAR stores variable-length strings up to a defined limit inline with the row; TEXT stores larger content, often off-page. Learn when to use each.
Published September 19, 2026
VARCHAR(n) stores a variable-length string up to n characters and is stored inline within the row. TEXT stores much larger variable-length text (up to 65,535 bytes for TEXT, more for MEDIUMTEXT/LONGTEXT) and in MySQL's InnoDB engine is typically stored off-page once it exceeds a certain size.
Common causes
- MySQL needs a defined maximum row size, so very large text content doesn't fit efficiently as an inline VARCHAR column
How to fix it
- Use VARCHAR(n) for short, bounded fields like names, emails, or slugs where you know a reasonable maximum length
- Use TEXT (or MEDIUMTEXT/LONGTEXT) for large content like article bodies, JSON blobs, or user-submitted comments where length isn't predictable
- Avoid indexing full TEXT columns directly — index a fixed-length prefix or use a full-text index if you need to search TEXT content
Example
CREATE TABLE articles (
title VARCHAR(255),
slug VARCHAR(255) UNIQUE,
content LONGTEXT
);FAQ
Is VARCHAR faster than TEXT?
For small-to-medium values, yes, generally — VARCHAR is stored inline with the row, avoiding the extra lookup TEXT sometimes requires when its content is stored off-page.