import html_to_json html_string = """<head> <title>Test site</title> <meta charset="UTF-8"></head>""" output_json = html_to_json.convert(html_string) print(output_json)