Saving faith is not void of works, yet we are saved through faith, not works (Ephesians 2:8,9).
In James 2:14, we read of one who says/claims he has faith but has no works. That is not genuine faith, but a bare profession of faith. So when James asks, "Can that faith save him?" he is saying nothing against genuine faith, but only against an empty profession of faith. James does not teach that we are saved "by" works. His concern is to show the reality of the faith professed by the individual (James 2:18) and demonstrate that the faith claimed (James 2:14) by the individual is genuine.
In James 2:19, nobody is questioning the fact that the demons believe "mental assent" that "there is one God" but they do not believe/entrust their spiritual well being to Christ; have faith/reliance upon Christ for salvation. Their trust and reliance is in Satan, as demonstrated by their rebellion in heaven and continuous evil works.
In James 2:21, notice closely that James does not say that Abraham's work of offering up Isaac resulted in God's accounting Abraham as righteous. The accounting of Abraham's faith as righteousness was made in Genesis 15:6, many years before his work of offering up Isaac recorded in Genesis 22. The work of Abraham did not have some kind of intrinsic merit to save his soul, but it proved or manifested the genuineness of his faith. *This is the sense in which Abraham was justified by works, "shown to be righteous."
In James 2:22, faith made perfect or complete by works means bring to maturity, carry to the end, to complete, just like love in 1 John 4:18. It doesn't mean that Abraham was finally saved based on the merits of his works when he offered up Isaac on the altar. When Abraham performed the good work in Genesis 22; he fulfilled the expectations created by the pronouncement of his faith in Genesis 15:6.
In James 2:23, the scripture was fulfilled in vindicating or demonstrating that Abraham believed God and was accounted as righteous. Abraham was accounted as righteous based on his faith (Genesis 15:6) not his works (Romans 4:2-3) long before he offered up Isaac on the altar in Genesis 22.
In James 2:24, James is not using the word "justified" here to mean "accounted as righteous" but is "shown to be righteous." James is discussing the proof of faith (says-claims to have faith but has no works/I will show you my faith by my works - James 2:14-18), not the initial act of being accounted as righteous with God (Romans 4:2-3).
In the Strong's Exhaustive Concordance of the Bible, the Greek word for justified "dikaioo" #1344 is:
1. to render righteous or such he ought to be
2. to show, exhibit, evince, one to be righteous, such as he is and wishes himself to be considered
3. to declare, pronounce, one to be just, righteous, or such as he ought to be
God is said to have been justified by those who were baptized by John the Baptist (Luke 7:29). This act pronounced or declared God to be righteous. It did not make him righteous. The basis or ground for the pronouncement was the fact that God IS righteous. Notice that the NIV reads, "acknowledged that God's way was right.." The ESV reads, "they declared God just.." This is the sense in which God was justified, "shown to be righteous" not accounted as righteous.
Matthew 11:19 "The Son of Man came eating and drinking, and they say, 'Behold, a gluttonous man and a drunkard, a friend of tax-gatherers and sinners!' Yet wisdom is justified/vindicated/shown to be right by her deeds."
In James 2:26, the comparison of the human spirit and faith converges around their modes of operation. The spirit (Greek pneuma) may also be translated "breath." As a breathless body emits no indication of life, so fruitless faith exhibits no indication of life. The source of the life in faith is not the works; rather, life in faith is the source of the works. Those who teach salvation by works put the cart before the horse.
In a nutshell, man is saved through faith and not by works (Ephesians 2:8,9; Titus 3:5; 2 Timothy 1:9); yet genuine faith is evidenced by works (James 2:14-26). Christ saves us through faith based on the merits of His finished work of redemption "alone" and not based on the merits of our works. It is through faith "in Christ alone" (and not by the merits of our works) that we are justified on account of Christ (Romans 3:24; 5:1; 5:9); yet the faith that justifies is never alone (solitary, unfruitful, barren) if it is genuine (James 2:14-26). *Perfect Harmony*