Location of Safari history

macOS
/Users/<username>/Library/Safari
/Users/<username>/Containers/com.apple.Safari/Data/Library/Preferences
/Users/<username>/Containers/com.apple.Safari/Data/Library/Cookies
/Users/<username>/Containers/com.apple.Safari/Data/Library/Caches/com.apple.Safari/TabSnapshots
/Users/<username>/Containers/com.apple.Safari/Data/Library/Caches/com.apple.Safari

Format of Safari history

Bookmarks
Safari Bookmarks are stored in the 'Bookmarks.plist' binary plist file within the 'Safari' folder.
Browser Settings
Safari Browser Settings are stored in the 'com.apple.Safari.plist' binary plist file within the 'Preferences' folder.
Cache
Safari Cache is stored using individual metadata and data (blob) files per cached resource.
Cookies
Safari Cookies are stored in the 'Cookies.binarycookies' file within the 'Cookies' folder.
Downloads
Safari Downloads are stored in the 'Downloads.plist' binary plist file within the 'Safari' folder.
Favicons
Safari Favicons are stored in the 'favicons.db' SQLite database within the 'Favicon Cache' folder. Favicon metadata is stored within the 'page_url' and 'icon_info' SQLite tables and the favicons themselves are stored within the 'favicons' subfolder.
Searches
Safari Searches are stored in the 'com.apple.Safari.plist' binary plist file within the 'Preferences' folder.
Session Data
Safari Session Data is stored in the 'LastSession.plist' and 'RecentlyClosedTabs.plist' binary plist files within the 'Safari' folder.
Site Settings
Safari Site Settings are stored in the 'PerSitePreferences.db' SQLite database within the 'Safari' folder.
Thumbnails
Safari Thumbnails are stored in the 'metadata.db' SQLite database within the 'TabSnapshots' folder. Thumbnail metadata is stored within the 'snapshot_metadata' SQLite table and the thumbnails themselves are stored as individual files in the same folder.
Website Visits
Safari Website Visits are stored in the 'History.db' SQLite database, within the 'history_visits' table. Associated URL information is stored within the 'history_items' table.