Blog/ Gmail how-tos

How Gmail Labels Map to IMAP Folders

Nafiul HasanNafiul Hasan· 12 min read
Diagram of how Gmail labels map to IMAP folders — one email carrying three labels appears in three separate folders while a single copy stays in All Mail

The short answer

Gmail does not use folders — it stores each message once in All Mail and attaches labels. Over IMAP, which only understands folders, Gmail exposes every label as a folder. A message with two labels appears in two folders, so the same email shows up twice — one message, two views.

How Gmail labels map to IMAP folders: Gmail exposes each label as a folder, so one message with several labels shows up in several folders at once.

On this page
  1. 01Gmail has labels; IMAP has folders
  2. 02Why one email shows up in several folders
  3. 03The system folders Gmail always shows
  4. 04The names can move; the special-use flag does not
  5. 05All Mail is the real store
  6. 06How labels travel over IMAP: the X-GM-LABELS extension
  7. 07Before you start
  8. 08Steps: control which labels become folders
  9. 09How different clients show the mapping
  10. 10What to do when it doesn't work
  11. 11A faster way to live with Gmail's labels

Connect Gmail to Apple Mail, Thunderbird, or Outlook and the same email can turn up in three folders at once. It confuses almost everyone the first time. The reason is not a sync bug: how Gmail labels map to IMAP folders is Gmail translating a labels model into a folders model, because IMAP only understands folders.

Gmail does not use folders internally. It stores each message a single time and attaches labels to it, like tags. When an IMAP client asks for your folder list, Gmail hands back every label dressed up as a folder. This post explains that mapping, backs it with Google's own IMAP documentation and the IMAP special-use standard, and shows exactly what changes when you delete, move, or rename.

Gmail has labels; IMAP has folders#

A folder holds a message in one place. Move the message and it leaves the old folder behind. A label is a tag: one message can carry many labels at once, and Gmail keeps only one copy of it no matter how many labels it has.

IMAP — the protocol Apple Mail and Thunderbird speak to Gmail — has no concept of a tag. It has only folders. So Gmail bridges the gap by presenting each label as a folder. Google states this plainly in its developer documentation: "Gmail treats labels as folders for the purposes of IMAP."

That one sentence explains the rest. A message tagged Work and Receipts is a single message with two labels. To IMAP it looks like one message inside a Work folder and one message inside a Receipts folder.

Why one email shows up in several folders#

Because the labels are real and the folders are a projection of them. Your client sees a Work folder and a Receipts folder, asks Gmail for the contents of each, and Gmail returns the same underlying message in both. Nothing is duplicated on Gmail's servers — you are looking at one message through two windows.

What differs is the client. Some clients notice that both copies share the same underlying message and collapse them into one; others show each folder's contents separately. That choice belongs to the client, not to Gmail.

One message, one ID

Gmail gives every message a single 64-bit identifier and exposes it to IMAP as X-GM-MSGID. When the same email appears in two folders, both entries carry that identical ID. That is how a client — or you — can prove it is one message, not two copies.

The system folders Gmail always shows#

Alongside your own labels, Gmail exposes a fixed set of system folders. Google nests them under a [Gmail] prefix (or [GoogleMail] on some accounts) so they do not collide with labels you created. Here is the common mapping.

Gmail labelIMAP folderWhat it is
InboxINBOXMessages that currently carry the Inbox label.
All Mail[Gmail]/All MailEvery message you have not deleted, whether or not it is in the Inbox. The real store.
Sent[Gmail]/Sent MailMessages you have sent, from any client.
Drafts[Gmail]/DraftsComposed but unsent messages.
Spam[Gmail]/SpamMessages Gmail classified as spam.
Trash[Gmail]/TrashMessages pending deletion, held about 30 days.
Starred[Gmail]/StarredStarred messages. Starring maps to the IMAP flagged keyword.
Important[Gmail]/ImportantMessages Gmail marked as important.

The names can move; the special-use flag does not#

The folder names above are Gmail's English defaults. A client may localize or relabel them, so do not hard-code the exact strings if you are writing a rule. The reliable, language-independent identifier is the IMAP special-use flag defined by RFC 6154, which Gmail advertises in its folder listing.

All Mail is the clearest example. Google's documented LIST response tags it * LIST (\HasNoChildren \All) "/" "[Gmail]/All Mail" — so a client that respects RFC 6154 finds the archive by its \All flag rather than by matching the text "All Mail". That is why a well-built client still finds the right folder on a German or Japanese account.

All Mail is the real store#

[Gmail]/All Mail is not another label folder — it is the archive that holds every message you have not deleted, in the Inbox or not. Archiving in Gmail simply removes the Inbox label; the message stays in All Mail the whole time.

This matches the IMAP special-use standard. RFC 6154 defines a \All mailbox as one that "presents all messages in the user's message store" and notes it "is almost certain to represent a virtual mailbox." Gmail's All Mail carries exactly that \All flag, which is what makes it a single view over one stored copy rather than a folder of duplicates.

Deleting from All Mail is the real delete

Removing a message's last label leaves it sitting in All Mail. But delete a message from All Mail and Gmail routes it to Trash, because there is only one copy to move — there is no per-label copy to fall back on. Empty Trash, or let 30 days pass, and it is gone from the account everywhere.

How labels travel over IMAP: the X-GM-LABELS extension#

Google added non-standard IMAP extensions so a client can read and change labels directly, instead of only through the folder illusion. The main one is X-GM-LABELS. Fetching it returns a message's labels as a list — Google's own example returns names such as \Inbox, \Sent, Important, and quoted multi-word labels like "Muy Importante".

A client can attach a label with a single STORE command, for example STORE 1 +X-GM-LABELS (foo). That adds the label without moving the message into a folder, which is how Gmail-aware clients avoid creating the duplicate-looking entries a plain folder move would.

Two companion extensions matter here too: X-GM-MSGID, the unique 64-bit message ID, and X-GM-THRID, the thread ID that groups a conversation the way Gmail's web view does. A third, X-GM-RAW, lets a client search with full Gmail search syntax. Most consumer clients ignore all of these and rely on the folder mapping instead — which is precisely why they show the duplicates.

Before you start#

Before you change anything, hold three facts in mind. You are editing live Gmail — every folder action syncs straight back to the web. All Mail is your safety net, not clutter to clear. And the client you use sets the defaults.

  • Confirm IMAP is on: Gmail Settings, Forwarding and POP/IMAP, Enable IMAP.
  • Know your client. Apple Mail, Thunderbird, and Outlook each handle Gmail's folders a little differently.
  • Decide what "delete" should mean before you delete. Gmail's IMAP settings control whether removing a message archives it or sends it to Trash.
  • Keep a way back. Nothing you do inside a label folder removes a message from All Mail, so archived mail is always recoverable there.

Steps: control which labels become folders#

You cannot turn off the label-to-folder mapping — it is how Gmail speaks IMAP. But you can control how much of it reaches your client, and what deletion does.

  1. 1

    Hide labels you do not browse

    In Gmail on the web, open Settings, See all settings, then the Labels tab. Each label has a Show in IMAP checkbox. Uncheck the ones you never open in your client and their folders disappear from the sidebar, cutting the duplicate count.

  2. 2

    Set what delete does

    In Settings, Forwarding and POP/IMAP, the Auto-Expunge option and the "last visible IMAP folder" option decide whether removing a message archives it or moves it to Trash. Choose deliberately before you rely on it.

  3. 3

    Find the real archive

    When a message seems missing, open [Gmail]/All Mail. It is not lost — it just has no label that your client is currently showing as a folder.

  4. 4

    Understand move versus relabel

    Dragging a message from one folder to another does not copy it. Gmail removes the source label and adds the destination label. Renaming a folder renames the label; deleting a folder deletes the label.

Menu names move; the behavior does not

Gmail reorganizes its settings pages from time to time, so a menu name here may have shifted. If Show in IMAP or Auto-Expunge is not where this says, look under Settings, See all settings. The underlying label-to-folder behavior stays the same even when the controls relocate — verified as of August 2026.

How different clients show the mapping#

The mechanism is identical everywhere; how much of it you see depends on the client. Here is how the common ones behave with a Gmail account, as of August 2026. Defaults change between versions, so check your client's current documentation before relying on a specific behavior.

ClientHow it shows labelsDelete defaultNotes
Apple Mail (macOS, iOS)Labels appear as mailboxes; [Gmail] system folders sit under the accountDepends on Mailbox Behaviors — Trash or Archive mappingLets you assign which Gmail folder acts as Trash, Archive, and Sent.
ThunderbirdShows every IMAP folder, including all [Gmail] onesRemoves the label or moves to Trash, per configThe most literal view of the mapping — you see All Mail and every label.
Outlook (classic desktop)Labels appear as folders under the Gmail accountMoves to Deleted Items or TrashBehavior follows how the account was added and its IMAP options.
New Outlook / Outlook on the webUses Microsoft's own account sync, not a direct IMAP folder viewVariesDuplication can look different from the clients above. Verify against Microsoft's current documentation.

The diagram below shows the shape of the whole thing: one stored message, several label-folders that each point back to it, and All Mail holding the single copy underneath. Every IMAP client has to reconstruct this from the folder list Gmail hands it.

Diagram showing one Gmail message routed to three separate IMAP folders labelled Work, Receipts, and Inbox, while a single stored copy remains in All Mail — illustrating how one message with several labels appears in several folders
One stored message, several label-folders. The folders are routes back to the same message in All Mail, not separate copies.

What to do when it doesn't work#

Most Gmail-over-IMAP "problems" are the mapping behaving exactly as designed. Match your symptom to its cause before you change settings.

SymptomCauseWhat to do
The same email is in several foldersIt carries several labels, and each label is a folderIgnore it — it is one message. To reduce the noise, hide labels you don't browse in Settings, Labels.
A message you archived vanishedArchiving removed the Inbox labelOpen [Gmail]/All Mail. The message is there; it just left the Inbox view.
Deleting in a label folder didn't remove the emailYou removed a label, not the messageTo delete for real, remove it from [Gmail]/All Mail, or empty [Gmail]/Trash.
A folder you expected is missingThat label's Show in IMAP is offRe-enable it in Settings, Labels. The folder reappears after the next refresh.
Renaming a folder renamed it in Gmail tooIMAP RENAME maps to renaming the labelExpected. There is no separate IMAP-only name — the folder is the label.
All Mail looks like it holds everything twiceAll Mail includes Inbox messages by designNot duplication. Inbox is a view of labeled messages; All Mail is the single store beneath it.

A faster way to live with Gmail's labels#

The controls above work, and if you run one Gmail account they may be all you need. The friction shows up with several accounts, or when you want one tidy view instead of a folder tree that repeats every message under every label.

AI Emaily reads Gmail through its labels — the same X-GM-LABELS data described above — and presents one unified inbox across your accounts, rather than reproducing each label as a folder that looks like a duplicate. It files with rules and a Personal Context brain you set directly, keeps All Mail as the untouched store underneath, and runs approve-before-send with undo and an audit trail on every action. It does not change Gmail's model; labels stay labels. It gives you a client-side triage layer over them. We build AI Emaily — see /pricing for the current plans.

Frequently asked

Nafiul Hasan

Written by

Nafiul Hasan

Nafiul Hasan is an entrepreneur and AI automation system builder with 10+ years of experience turning messy, manual workflows into reliable automated systems. He designs and ships AI enterprise solutions end-to-end — the agent logic, the data plumbing, and the product people actually use — and founded AI Emaily to give busy professionals their attention back. He writes here from the builder's seat: what works, what breaks, and how to put AI to work without giving up control.

EntrepreneurAI Automation System BuilderAI EnthusiastBuilds AI Enterprise Solutions10+ years experience
More from Nafiul
Ready when you are

Gmail's labels-as-folders is a translation, not a setting you can switch off.

AI Emaily reads Gmail through its labels and keeps one message as one message — connect Gmail, Outlook, iCloud, and IMAP accounts in a single view, with approve-before-send and a full audit log. 7-day free trial at aiemaily.com.

  • 7-day free trial
  • Cancel anytime
  • Every provider