CSS Mobile-First Converter

Paste CSS written with max-width media queries and get min-width breakpoints, sorted from small to large. Runs in your browser - your code is never uploaded.

Free to use No signup Runs in your browser Nothing is stored

Convert max-width to min-width

Paste your CSS on the left, press Convert, and copy the result from the right.

Lines: 0  |  Media queries found: 0  |  Converted: 0

Tip: press Ctrl + Enter (Cmd + Enter on Mac) to convert.

Please review the output. The tool replaces each max-width: Npx with min-width: N.02px and orders the blocks from smallest to largest. Because the meaning of a breakpoint flips (styles that applied below N now apply above it), you should also move your small-screen styles into the base rules. See the guides on our blog for how to do that step by step.

What is mobile-first CSS?

Mobile-first CSS means the base styles are written for small screens, and min-width media queries add layout changes as the screen gets wider. Desktop-first CSS does the opposite: base styles target large screens, and max-width queries override them for smaller screens.

 Desktop-firstMobile-first
Media query@media (max-width: 768px)@media (min-width: 768px)
Base styles forLarge screensSmall screens
OverridesScale downScale up

How to use this tool

  1. Paste your CSS (with @media (max-width: ...px) queries) into the input box.
  2. Press Convert Now.
  3. Copy the result and review it in your editor, moving small-screen rules into the base styles where needed.

Why the 0.02px offset?

At exactly 768px, max-width: 768px and min-width: 768px are both true, so both rules would apply. Using 768.02px for the min-width side keeps the two ranges from overlapping.

Privacy

The conversion is plain JavaScript running in your browser. Your CSS is not sent to any server.

Frequently asked questions

Is this tool free?

Yes. There is no signup and no usage limit.

Is my CSS uploaded anywhere?

No. Everything happens inside your browser tab.

Does it handle units other than px?

It converts max-width values written in pixels. Queries in em or rem are left unchanged, so convert those by hand.

Can I paste a very large file?

Yes, but for files over a few hundred KB it is smoother to convert them in sections.

Will the converted CSS work as-is?

Not always. The breakpoints are flipped and sorted, but you still need to check which rules belong in the base styles. Read our guides on the blog for details.

Latest articles

Friday, 27 November 2026

How to Choose CSS Breakpoints: A Practical Mobile-First Guide



When you write mobile-first CSS, the base styles are for small screens and each min-width media query adds changes as the screen gets wider. The big question is: which widths should you pick? This guide gives you a practical starting set and a better way to choose your own.

A good starting set of breakpoints

There is no official standard, but these four values cover most phones, tablets, laptops and large monitors:

BreakpointTypical devicesUsual change
Base (no query)PhonesSingle column, stacked layout
480pxLarge phones, landscapeSlightly larger spacing
768pxTabletsTwo columns, show full navigation
1024pxSmall laptopsThree columns, sidebar appears
1280pxDesktopsWider container, more whitespace
/* Base: mobile styles, no media query */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

Rule 1: Let the content choose the breakpoint

Device widths change every year, so a breakpoint tied to one phone model gets outdated quickly. A better method is to start with the narrowest layout and slowly widen the browser. The moment the layout looks stretched or awkward, add a breakpoint at that width. Your design decides the numbers, not a device list.

Tip: if a line of text gets longer than about 75 characters, that is often a good sign it is time for a new layout.

Rule 2: Use as few breakpoints as you can

Every breakpoint is one more state to test and maintain. Many sites work well with just two or three. If a component only needs a change at one width, give that component its own breakpoint instead of forcing it to follow a global list.

Rule 3: Use CSS variables for the values you repeat

Media queries cannot read CSS custom properties, so you can not write @media (min-width: var(--tablet)). Instead, keep your breakpoints in one place by writing them as a short comment block at the top of your stylesheet, or use a preprocessor variable if you use Sass:

/* Breakpoints
   sm: 480px | md: 768px | lg: 1024px | xl: 1280px */

Rule 4: Prefer min-width, and avoid mixing

Stick with min-width across the whole file. Mixing max-width and min-width makes the cascade harder to follow, and it can leave a gap or an overlap at the exact breakpoint. If you are moving an older desktop-first stylesheet, the free ConvertSwift max-width to min-width converter flips the queries and sorts them from small to large for you.

Rule 5: Keep media queries in order

Because later rules override earlier ones, mobile-first queries should go from smallest to largest. If a 1024px rule comes before a 768px rule, the 768px rule can win on large screens by accident.

/* Correct order: small to large */
@media (min-width: 768px)  { ... }
@media (min-width: 1024px) { ... }
@media (min-width: 1280px) { ... }

px, em or rem for breakpoints?

Pixels are simple and are what most developers use. However, em based breakpoints respond to the user's browser font size, so the layout adapts when someone has increased their default text size. In media queries, em is based on the browser's default font size (usually 16px), so 48em equals 768px by default. Either choice is fine, just stay consistent in one project.

Common mistakes

  • Writing desktop styles first, then overriding them for mobile.
  • Adding too many breakpoints "just in case".
  • Putting queries in the wrong order.
  • Testing only at exact breakpoint widths and not in between.
  • Forgetting the viewport tag: <meta name="viewport" content="width=device-width, initial-scale=1">

Quick recap

  • Write base styles for mobile, then add min-width queries.
  • 480, 768, 1024 and 1280px are a solid starting set.
  • Let your content decide the real breakpoints.
  • Keep queries ordered from small to large.

FAQ

How many breakpoints should I use?

Two to four is enough for most websites. Add more only when the layout really breaks.

Is 768px still a good tablet breakpoint?

Yes, it is a widely used value. Treat it as a starting point and adjust to your design.

Can I use min-width and max-width together?

You can, for a query that applies only inside a range, but for most projects it is simpler to use only min-width.

CSS clamp() Explained: Smooth Responsive Font Sizes Without Media Queries


Most CSS files have a block like this somewhere: the heading is 2rem on desktop, then a media query drops it to 1.75rem on tablets, and another one drops it to 1.5rem on phones. It works, but the text jumps in steps, and every new size means another rule to maintain.

CSS clamp() lets one line of CSS do the job of all three. The font size grows smoothly with the screen, but never goes below a minimum or above a maximum.

What is clamp()?

clamp() takes three values: a minimum, a preferred value and a maximum.

font-size: clamp(1rem, 2.5vw, 2rem);
  • 1rem is the smallest the text can be.
  • 2.5vw is the preferred size. It is 2.5% of the viewport width, so it scales with the screen.
  • 2rem is the largest the text can be.

The browser uses the preferred value while it stays between the minimum and maximum. Once it goes outside that range, the nearest limit wins.

The old way vs. the clamp() way

/* Desktop-first, three rules */
h1 { font-size: 2rem; }
@media (max-width: 1024px) { h1 { font-size: 1.75rem; } }
@media (max-width: 600px)  { h1 { font-size: 1.5rem; } }

/* With clamp(), one rule */
h1 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem); }
Media queriesclamp()
Size changesIn steps at breakpointsSmoothly at every width
Lines of CSSOne rule per breakpointOne line
MaintenanceUpdate every breakpointUpdate min, preferred or max

Why not use vw alone?

A font size written only in vw units has a real accessibility problem: when a visitor zooms the page, the text may not grow with it. Mixing a rem amount into the preferred value, such as 1.2rem + 1.5vw, keeps the text responsive to zoom and to the user's browser font settings. Using rem for the minimum and maximum helps too.

Tip: always put a rem part in the preferred value, not just vw.

A simple formula for the preferred value

Say you want text that is 16px on a 320px screen and 24px on a 1200px screen.

  1. Slope = (24 - 16) / (1200 - 320) = 0.00909, which is 0.909vw.
  2. Intercept = 16 - (0.00909 x 320) = 13.09px, which is about 0.818rem (at a 16px root size).
  3. Put it together:
font-size: clamp(1rem, 0.818rem + 0.909vw, 1.5rem);

At 320px wide this gives 16px, at 1200px wide it gives 24px, and anywhere in between it scales evenly.

Copy-paste type scale

:root {
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);   /* body */
  --step-1: clamp(1.25rem, 1.1rem + 0.75vw, 1.625rem); /* h3 */
  --step-2: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);    /* h2 */
  --step-3: clamp(1.875rem, 1.3rem + 2.5vw, 3rem);     /* h1 */
}

body { font-size: var(--step-0); }
h3   { font-size: var(--step-1); }
h2   { font-size: var(--step-2); }
h1   { font-size: var(--step-3); }

This is already mobile-first: the smallest value in each clamp() is the phone size, and larger screens scale up from there.

Beyond font size

clamp() works anywhere CSS accepts a length, so you can use it for spacing too:

.section { padding: clamp(1rem, 4vw, 3rem); }
.container { width: clamp(280px, 90%, 1100px); }

When you still need media queries

clamp() is great for sizes and spacing, but it does not replace layout changes. Switching from one column to three, hiding a menu or moving a sidebar still needs @media (min-width: ...). If your stylesheet is still written with max-width queries, you can convert it with the free ConvertSwift CSS converter, then use clamp() to remove the media queries that only existed to resize text.

Browser support

clamp() is supported in all current major browsers, so you can use it in production today. If you must support very old browsers, put a plain fallback line first:

h1 {
  font-size: 1.75rem;                         /* fallback */
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
}

Quick recap

  • clamp(min, preferred, max) gives you smooth, limited scaling in one line.
  • Mix rem and vw in the preferred value so zoom still works.
  • Use the slope and intercept formula to hit exact sizes at two screen widths.
  • Keep media queries for layout changes, and use clamp() for sizing.

FAQ

Can I use clamp() with px units?

Yes, but rem is better for accessibility because it respects the user's font size settings.

Does clamp() replace min-width media queries?

No. It replaces the ones that only change sizes or spacing. Layout changes still need media queries.

Can I mix units inside clamp()?

Yes. You can mix rem, vw, px and percentages, and you can add them with calc()-style math directly, like 1.2rem + 1.5vw.

Free CSS Mobile-First Converter: Turn max-width into min-width Instantly




Most websites on the internet were not built mobile-first. Many stylesheets still start with a desktop layout and then patch smaller screens using @media (max-width: ...) queries. It works, but it often leads to long override chains and CSS that is hard to maintain.

CSS Mobile-First Converter at convertswift.online is a free tool that fixes this. Paste your desktop-first CSS, click one button, and get mobile-first min-width CSS back.

What does the tool do?

It takes media queries like this:

@media (max-width: 768px) {
  .card { width: 100%; }
}

and converts them to the mobile-first equivalent:

@media (min-width: 768.02px) {
  .card { width: 50%; }
}

The breakpoints are also sorted in ascending order, which is how mobile-first CSS is meant to be written: small screens first, then larger ones.

Why the 0.02px offset?

At exactly 768px, both max-width: 768px and min-width: 768px are true, so both rules would apply at once. Using 768.02px keeps the two ranges from overlapping. The tool handles this automatically, so you don't have to calculate it by hand.

Why go mobile-first?

  • Mobile-first indexing: Google primarily uses the mobile version of a site for indexing, so CSS written around small screens fits that approach.
  • Leaner stylesheets: Base styles target small screens, and larger screens only add what they need. This usually means fewer overrides.
  • Easier maintenance: Fewer conflicting rules make debugging simpler for you and your team.
  • Framework compatibility: Tailwind CSS and Bootstrap 5 both follow the mobile-first convention, so migrating legacy CSS makes integration easier.
  • Mobile audience: A large share of web traffic comes from phones, so it makes sense to design for them first.

How to use it

  1. Paste your CSS with max-width media queries into the input panel.
  2. Click "Convert Now" (or press Ctrl + Enter).
  3. Copy the result with one click and paste it into your project.

There are also Load Sample, Swap and Clear buttons, plus a counter showing how many media queries were found and converted.

Private and free

All conversion runs in your browser with JavaScript. Your CSS is never uploaded, stored or sent to a server. There is no signup, no account and no usage limit, so you can convert as many files as you need.

A quick note on results

The converter flips and sorts your breakpoints, but you should still review the output. Some rules may need to move into your base styles, and queries written in em or rem need to be converted by hand. For very large stylesheets, converting in sections keeps your browser smooth.

Try it now

If you are refactoring a legacy codebase or just want cleaner responsive CSS, give it a try at convertswift.online. You can also read our guides on mobile-first CSS, breakpoints and Core Web Vitals on the blog.

Max-width vs min-width: Which Media Query Should You Use




If you have ever opened an old stylesheet and found a pile of @media (max-width: ...) rules, you have seen desktop-first CSS. Most modern guides recommend the opposite: write for small screens first and use min-width to add layout as the screen grows. This article explains the difference in plain terms, shows a real before-and-after example, and covers the mistakes that usually appear when people convert old code.

The short answer

max-width means "apply these styles when the screen is this wide or smaller". min-width means "apply these styles when the screen is this wide or larger". That is the entire technical difference. The bigger difference is in how you think about your design.

Desktop-firstMobile-first
Media querymax-widthmin-width
Base styles are forLarge screensSmall screens
Media queriesUndo or shrink thingsAdd or expand things
Phone getsBase CSS plus many overridesOnly the base CSS

What desktop-first looks like

In a desktop-first stylesheet, the base rules describe the wide layout. Every smaller screen then needs overrides to take that layout apart again.

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

This works, but a phone has to read the three-column rule first and then cancel it. As the project grows, these overrides pile up and it becomes hard to tell which rule is actually winning.

The same layout, mobile-first

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

Now the base rule is the simplest possible layout, and each breakpoint only adds something. The breakpoints also read in the same order as the screen grows, from small to large, which makes the file much easier to scan.

Why mobile-first is usually the better choice

  • Less to undo. Small screens get the simple styles directly instead of loading complex ones and cancelling them.
  • Easier to read. Breakpoints go in one direction, so you never need to ask "which query overrides which".
  • Matches how people browse. A large share of web traffic comes from phones, so it makes sense for them to be the default case.
  • Forces you to prioritise. With limited space you decide early what content really matters.

That said, desktop-first is not "wrong". If you maintain a large existing site and it works, rewriting everything just for the sake of it may not be worth the time. Convert it gradually, one component at a time.

The overlap problem at exact breakpoints

This one catches many people. If you write max-width: 768px and min-width: 768px, both conditions are true when the viewport is exactly 768px wide, so both rules apply at the same moment. There are two common ways to avoid it:

  • Use a different number on each side, for example max-width: 768px and min-width: 769px.
  • Use a small decimal such as min-width: 768.02px. Some browsers handle fractional widths on high-density screens, and the decimal keeps the two ranges from touching.

If you only use one direction in a project (all min-width), this problem mostly disappears, which is one more point in favour of mobile-first.

How to convert old max-width CSS

Simply replacing the word max-width with min-width will break your layout, because the meaning flips. Follow these steps instead:

  1. List your breakpoints. Search the file for every @media rule and write the widths down.
  2. Pick the small-screen version of each component. This becomes your new base style.
  3. Move the old desktop styles into min-width blocks. These now describe what changes when the screen gets larger.
  4. Order the blocks from smallest to largest. Later rules win when specificity is equal, so the order matters.
  5. Test at the edges. Check the layout just below and just above each breakpoint, not only on your own phone.

The mechanical part of this, swapping the queries and sorting the blocks, can be done automatically with the max-width to min-width converter on this site. The second part, moving your small-screen styles into the base rules, still needs a human, so review the output before you ship it.

Common mistakes

  • Mixing both directions in one stylesheet. It is possible, but it quickly becomes confusing. Choose one.
  • Forgetting the viewport meta tag. Without <meta name="viewport" content="width=device-width, initial-scale=1">, phones may pretend to be wider than they are and your media queries will not behave as expected.
  • Using device names as breakpoints. Do not design for "iPhone" or "iPad". Add a breakpoint where your content starts to look bad.
  • Leaving fixed widths in the base rules. A width: 1100px on a container will cause sideways scrolling on a phone. Prefer max-width as a property with width: 100%.

Frequently asked questions

Does min-width make my site faster?

Not directly. The speed benefit comes from the simpler code that mobile-first tends to produce. A phone does not need to parse and then cancel desktop-only layout rules.

Can I use both max-width and min-width together?

Yes. For example, @media (min-width: 600px) and (max-width: 899px) targets only a range. It is useful for a rule that should apply to tablets only, but use it sparingly.

What breakpoints should I use?

There is no perfect set. Common starting points are around 600px, 768px and 1024px, but the best method is to resize your browser and add a breakpoint wherever the design starts to break.

Do I have to convert my whole site?

No. If the existing code works, convert it step by step, starting with the components you touch most often.

Conclusion

The difference between max-width and min-width is small in syntax but large in effect. Writing small-screen styles first gives you simpler base code, fewer overrides and breakpoints that read in a natural order. If you are starting a new project, go mobile-first from day one. If you have an old stylesheet, convert it in small steps and test at every breakpoint.

ConvertSwift | Free CSS Mobile-First Converter (max-width → min-width)

Search This Blog

Blog Archive

Powered by Blogger.

How to Choose CSS Breakpoints: A Practical Mobile-First Guide

When you write mobile-first CSS, the base styles are for small screens and each min-width media query adds changes as the screen gets w...