Crisps, chocolate and sugary drinks are to be removed from vending machines in NHS hospitals in Wales.
Health Minister Edwina Hart says Wales is the first part of the UK to commit to such a move to tackle obesity and diet-related disease.
It is part of the Labour-Plaid Cymru assembly government's commitment in the deal which created their coalition to improve hospital food and nutrition.
Most junk food will be removed from the machines in the next six months.
Only one NHS hospital in Wales out of 130 will not have healthy vending in place by 2010.
Almost 20% of six to 13-year-olds in Wales are overweight or obese - the highest rate in the UK - as are six out of every 10 men, and half of women.
The assembly government believes hospitals in particular should show best practice in providing health options.
The assembly government said it would liaise with vending machine providers to find ways of introducing healthier food and drink.
Guidance will be issued to support the change, providing clear definitions of what will be allowed in the machines.
Vanessa Bourne, from the Patients Association, said many patients would be "very glad" to have a choice.
But she said: "It's important that it is a choice and not just a blanket ban on certain things.
"A choice is the obvious way to go and to educate people in the most meaningful sense. But also we need to be aware that the healthy option shouldn't become the expensive option because if it is, it won't work."
Ms Hart said: "Diet has an important role to play in the prevention of obesity and chronic diseases such as coronary heart disease, diabetes and certain cancers.
"The assembly government is committed to improving the health of the population of Wales and reducing inequalities by tackling the underlying causes of ill health."
"We need to create an environment where it is easier for people to make healthy choices and our public sector settings should be an exemplar of best practice, particularly our hospitals.
"This is the first stage of the work to improve hospital food," Ms Hart added.
"We will be speaking with WRVS (Women's Royal Voluntary Service) and other outlets in hospitals about further ways they can support the broader over-arching agenda to improve nutrition in hospitals."
A study carried out by Cardiff's University Hospital of Wales which looked at vending machines in or near paediatric departments in Welsh hospitals showed very few NHS trusts had any machines where half of more of the drinks were healthy.
Huw Jenkins, consultant paediatric gastroenterologist at the hospital, said: "It is clear from a recent survey that the majority of vending machines around children's areas in Welsh hospitals do not provide enough healthy options.
He said the minister's announcement would ensure "all vending machines are stocked with healthy options in the future".
The vending machine ban follows a report from a group set up last year and chaired by the chief nursing officer for Wales, to improve patients' food and drink.
Similar work is being undertaken on vending both in schools and in leisure centres.
It also follows an announcement earlier this month of plans to improve oral health by giving children as young as three free toothbrushes, as well as lessons in how to use them.