You generally will owe tax on this type of withdrawal as well as a 10% penalty. There are some exceptions to the 10% penalty and the IRS does not have an exception that relates directly to an early hardship withdrawal. There are exceptions though, that may help a taxpayer claim an exception for costs related to a hardship. For example, you may claim an exception for any portion of the funds withdrawn and used to pay medical bills.
Please view the link below as number seven relates to your question.
https://www.irs.gov/retirement-plans/retirement-plans-faqs-regarding-hardship-distributions
Please view this link as well. It gives a list of all possible exceptions.
https://www.irs.gov/retirement-plans/plan-participant-employee/retirement-topics-tax-on-early-distri...