You can use PowerShell command to export the term store in SharePoint 2013 into CSV file, and then import to SharePont Online.
More information and PowerShell command check the article:
PowerShell for SharePoint 2013: Export TermSet to CSV
Migrate SharePoint 2010 Term Store to SharePoint Online with PowerShell