6 habits to start in your 20s if you want to retire by 40

Peopleimages | Getty Images

If you want to retire early, you're going to have to start saving early. That part's clear. The tricky part is actually establishing the habits that will help you reach your goal.

Luckily, a handful of everyday people who have reached financial independence at a young age have shared their top tips to help you try to do the same.

Here are six tested and helpful habits to establish in your 20s if you want to settle down before 40.

Track your expenses

Whether you track your purchases in a spreadsheet or have an app like Mint or You Need a Budget do it for you, knowing how much you bring in and you how much you shell out is crucial.

Many early retirees started their journey to financial independence by analyzing their spending habits and figuring out exactly how much they need to retire comfortably. "You have to know what you are spending before you can plan your retirement budget," says Justin McCurry, who retired with more than $1 million in his 30s.

Retire by 40 by giving up these habits

Set clear and specific retirement goals

If you've set a target date, you're on the right track to retiring early. You'll also want to make a retirement budget, which will help you figure out exactly how big your portfolio needs to be to last through your golden years.

Many early retirees use the "four-percent rule" — the formula some say can help you figure out the amount you can withdraw from your retirement savings each year without running out — to help them determine their magic number.

Pay yourself first

Once you've established a plan, you can focus on execution, which all starts with paying yourself first — meaning that you consistently send a chunk of your income to a tax-advantaged retirement account, such as a 401(k), Roth IRA or traditional IRA. The earlier you want to retire, the greater the percentage should be.

Pro tip: Automate. If you have a certain percentage of your paycheck automatically sent straight to your savings, retirement or investment account, you'll never even see that money and won't be tempted to spend it.

24-year-old Silicon Valley engineer lives in his truck and saves 80% of his income

Save half your income

Most early retirees have the discipline to keep a large chunk of their paycheck — often, more than half of it — thanks to a variety of strategies you can check out here.

If you're working towards setting aside 50 percent of your paycheck, you're well on your way to financial freedom.

Think about purchases in terms of cost per hour

"To achieve a high savings rate, start viewing your purchases in terms of units of your time rather than dollars," of "The Money Habit," who stashed more than 70 percent of her income and built a nest egg of $2.25 million before age 30. "So instead of saying a new unlocked iPhone costs $800, you might do the math to figure out it would cost you 60 hours of work, or a week and a half of your life."

It makes you question whether any given item is really worth the money — which is to say, the effort and the time.

"This is great for big purchases," the New York City-based early retiree tells CNBC Make It. "To buy a home with an extra bedroom or one with fancier finishings might cost you $50,000 or $100,000. Is that worth working three extra years to you?"

A New York City-based millennial who retired with $2.25 million says this is the key to saving

Maximize your income

If you're thinking about ways to generate more income, in addition to saving a ton, you're on a good path.

As early retiree Chris Reining tells CNBC: "At a certain point, you need to figure out how you can make more money, because that's really limitless. You're never going to get to zero spending, but you can always make more money, so once you get to a balance of spending that you're comfortable with, focus on pulling on that other lever that you have, which is making more money."

Increasing your revenue streams could mean finding a part-time job, starting a side hustle or establishing passive income.

This is an update of a previously published story.

Don't miss: We looked at the 25 most popular cash back credit cards—here's our pick for No. 1

Like this story? Subscribe to CNBC Make It on YouTube!

How this average 38-year-old became a millionaire and retired early