with open("data.json", 'r') as data: login = json.loads(data.read()) # then you can use it like this if login_username == login['Username'] and login_password == login['Password']: ... Rest of the code