High level NPC's in particular cannot be created with Players Handbook rules because they're ineffective. They need to be created with monster rules. A CR17 NPC needs at least 300HP to survive one round of combat.
This is true, so I use
http://rpgtinker.com/ and crank up the hit dice to say 20d12 for a caster type. It maxes at 30d20 which is good for a powerful warrior or demigod type. Here's what I get for a maxed-out
Drow Evoker, which took about 5 seconds. IRL I would edit it for another 2-3 minutes. Not sure I believe the CR, seems low.
Uthque : Evoker
Female Drow, any alignment
Armor Class: 16 (with mage armor)
Hit Points: 405 (30d20 +90)
Speed: 30ft (9m / 6 sqr)
Proficiency: +9
STR
10 (+0)
DEX
16 (+3)
CON
16 (+3)
INT
20 (+5)
WIS
12 (+1)
CHA
15 (+2)
Skills: Perception +10 Arcana +14 Intimidation +11 Stealth +12 Persuasion +11
Saving Throws: Intelligence +14 Constitution +12
Challenge: 14 (15000 XP)
Racial Features
Ability Modifiers: +2 Dex, +1 Cha
Fey Ancestry: You have advantage on saving throws against being charmed, and magic can’t put you to sleep.
Superior Darkvision: 120ft (36m / 24sqr)
Sunlight Sensitivity: Disvantage on attack rolls and wisdom perception (sight) when your target is on direct sunlight
Trance: meditate for 4 hours instead of sleep.
Keen Senses: proficiency in the Perception skill.
Drow Weapon Training: proficiency with the rapiers, shortswords, and hand crossbows (not considered for template)
Drow Magic: know Dancing Lights cantrip, once per day can cast Faerie Fire (if CR is greater than 3) and Darkness, also once per day (if CR is greater than 5). Charisma as spellcasting ability for those spells
Languages: speaks Elvish and Undercommon.
Actions
Quarterstaff. Melee Weapon Attack +9 to hit, reach 5 ft, one target. Hit: 14 (4d6 +0 ) bludgeoning damage.
Properties: Versatile (1d8),
Spells
Spellcasting. the Evoker is an 30th-level wizard. Its spellcasting ability is Intelligence (spell save DC 22, to hit with spell attacks +14)
Cantrips (at will): Prestidigitation, Acid Splash, Mage Hand, Ray of Frost, Dancing Lights,
1st level (4 slots): Feather Fall, Thunderwave, Mage Armor,
2nd level (3 slots): Cloud of Daggers, Web, Melf's Acid Arrow, Darkvision,
3rd level (3 slots): Counterspell, Lightning Bolt, Fly, Blink,
4th level (3 slots): Dimension Door, Ice Storm, Wall of Fire, Greater Invisibility,
5th level (3 slots): Bigby's Hand,
6th level (2 slots): Circle of Death, Chain Lightning,
7th level (2 slots): Delayed Blast Fireball, Reverse Gravity,
8th level (1 slots): Sunburst, Incendiary Cloud,
9th level (1 slots): Meteor Swarm,