You can technically use it however you see fit if you are willing to pay the 10% IRS penalty. Money from 529 Plans can be used for tuition, books, supplies, room and board and, as of recently, computers and electronic necessities.
Always check if you’re not sure that an expense is covered by the 529 plan. Money used for anything other than the specified costs will be subject to federal income taxes and a 10% penalty on the earnings. You can also transfer the account to another beneficiary or yourself if you or someone else will need the money for college one day, without incurring any penalties or taxes.
Unlike Health Savings Accounts, which can be used penalty-free for any purpose after age 65, there is never an age at which a 529 can be spent on anything other than education without incurring a penalty. You also cannot use 529s for any education that leads up to college level courses, so it will not help for expensive private elementary schools or high schools.
It will, however, cover college-level courses taken during high school if the costs are out-of-pocket for the parents. Coverdell Education Savings Accounts can be used for non-college education expenses, but their contribution limits are quite low these days since they have not been adjusted for inflation.
What role does inflation play in my retirement planning?
Will Having a 529 Plan for My Child Impact His/Her Eligibility For Financial Aid in the Future?
What are the Contribution Limits For My 529 Plan?