Who is Ginny Weasley closer to, Hermione Granger or Luna Lovegood?
Ginny was close to both, in different ways.
Ginny and Hermione had become close in Ginny's second year; Hermione comforted Ginny that year when the presence of Dementors upset her. Hermione stayed in Ginny's room during her frequent visits to the Burrow during the summer holidays. Ginny was the one who Hermione confided in when Viktor Krum asked her to the Yule Ball, and later when she had kissed him at least once. Ginny also told Hermione about her teaching herself how to fly and about her relationship with Michael Corner before her family and most others were aware of either.
Ginny was friendly with Luna, although they didn’t grow close until they were both members of Dumbledore's Army in their fourth year.
Ginny stood up to those who ridiculed Luna. In return, Luna genuinely appreciated Ginny's friendship; she once mentioned how much she liked Ginny while commentating on a Gryffindor-Hufflepuff Quidditch match in which Ginny was playing Chaser.
Ginny was also one of the five portraits — along with Harry, Ron, Hermione, and Neville — that Luna painted and hung from her bedroom ceiling, with the message "friends" joining them together in gold writing.
Ginny later gave her daughter Lily the middle name "Luna", implying that the two remained very close well into adulthood.